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