clang API Documentation

DeltaTree.h
Go to the documentation of this file.
00001 //===--- DeltaTree.h - B-Tree for Rewrite Delta tracking --------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file defines the DeltaTree class.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_CLANG_REWRITE_CORE_DELTATREE_H
00015 #define LLVM_CLANG_REWRITE_CORE_DELTATREE_H
00016 
00017 #include "llvm/Support/Compiler.h"
00018 
00019 namespace clang {
00020 
00021   /// DeltaTree - a multiway search tree (BTree) structure with some fancy
00022   /// features.  B-Trees are generally more memory and cache efficient than
00023   /// binary trees, because they store multiple keys/values in each node.  This
00024   /// implements a key/value mapping from index to delta, and allows fast lookup
00025   /// on index.  However, an added (important) bonus is that it can also
00026   /// efficiently tell us the full accumulated delta for a specific file offset
00027   /// as well, without traversing the whole tree.
00028   class DeltaTree {
00029     void *Root;    // "DeltaTreeNode *"
00030     void operator=(const DeltaTree &) LLVM_DELETED_FUNCTION;
00031   public:
00032     DeltaTree();
00033 
00034     // Note: Currently we only support copying when the RHS is empty.
00035     DeltaTree(const DeltaTree &RHS);
00036     ~DeltaTree();
00037 
00038     /// getDeltaAt - Return the accumulated delta at the specified file offset.
00039     /// This includes all insertions or delections that occurred *before* the
00040     /// specified file index.
00041     int getDeltaAt(unsigned FileIndex) const;
00042 
00043     /// AddDelta - When a change is made that shifts around the text buffer,
00044     /// this method is used to record that info.  It inserts a delta of 'Delta'
00045     /// into the current DeltaTree at offset FileIndex.
00046     void AddDelta(unsigned FileIndex, int Delta);
00047   };
00048 }  // end namespace clang
00049 
00050 #endif