clang  7.0.0svn
DeltaTree.h
Go to the documentation of this file.
1 //===- DeltaTree.h - B-Tree for Rewrite Delta tracking ----------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the DeltaTree class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_REWRITE_CORE_DELTATREE_H
15 #define LLVM_CLANG_REWRITE_CORE_DELTATREE_H
16 
17 namespace clang {
18 
19  /// DeltaTree - a multiway search tree (BTree) structure with some fancy
20  /// features. B-Trees are generally more memory and cache efficient than
21  /// binary trees, because they store multiple keys/values in each node. This
22  /// implements a key/value mapping from index to delta, and allows fast lookup
23  /// on index. However, an added (important) bonus is that it can also
24  /// efficiently tell us the full accumulated delta for a specific file offset
25  /// as well, without traversing the whole tree.
26  class DeltaTree {
27  void *Root; // "DeltaTreeNode *"
28 
29  public:
30  DeltaTree();
31 
32  // Note: Currently we only support copying when the RHS is empty.
33  DeltaTree(const DeltaTree &RHS);
34 
35  DeltaTree &operator=(const DeltaTree &) = delete;
36  ~DeltaTree();
37 
38  /// getDeltaAt - Return the accumulated delta at the specified file offset.
39  /// This includes all insertions or delections that occurred *before* the
40  /// specified file index.
41  int getDeltaAt(unsigned FileIndex) const;
42 
43  /// AddDelta - When a change is made that shifts around the text buffer,
44  /// this method is used to record that info. It inserts a delta of 'Delta'
45  /// into the current DeltaTree at offset FileIndex.
46  void AddDelta(unsigned FileIndex, int Delta);
47  };
48 
49 } // namespace clang
50 
51 #endif // LLVM_CLANG_REWRITE_CORE_DELTATREE_H
void AddDelta(unsigned FileIndex, int Delta)
AddDelta - When a change is made that shifts around the text buffer, this method is used to record th...
Definition: DeltaTree.cpp:456
int getDeltaAt(unsigned FileIndex) const
getDeltaAt - Return the accumulated delta at the specified file offset.
Definition: DeltaTree.cpp:409
DeltaTree & operator=(const DeltaTree &)=delete
DeltaTree - a multiway search tree (BTree) structure with some fancy features.
Definition: DeltaTree.h:26
Dataflow Directional Tag Classes.