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