1 //===--- DeltaTree.h - B-Tree for Rewrite Delta tracking --------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the DeltaTree class.
12 //===----------------------------------------------------------------------===//
14 #ifndef CLANG_REWRITE_DELTATREE_H
15 #define CLANG_REWRITE_DELTATREE_H
17 #include "llvm/Support/Compiler.h"
21 /// DeltaTree - a multiway search tree (BTree) structure with some fancy
22 /// features. B-Trees are generally more memory and cache efficient than
23 /// binary trees, because they store multiple keys/values in each node. This
24 /// implements a key/value mapping from index to delta, and allows fast lookup
25 /// on index. However, an added (important) bonus is that it can also
26 /// efficiently tell us the full accumulated delta for a specific file offset
27 /// as well, without traversing the whole tree.
29 void *Root; // "DeltaTreeNode *"
30 void operator=(const DeltaTree &) LLVM_DELETED_FUNCTION;
34 // Note: Currently we only support copying when the RHS is empty.
35 DeltaTree(const DeltaTree &RHS);
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;
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);
48 } // end namespace clang