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 CLANG_REWRITE_DELTATREE_H
00015 #define CLANG_REWRITE_DELTATREE_H
00016 
00017 namespace clang {
00018 
00019   /// DeltaTree - a multiway search tree (BTree) structure with some fancy
00020   /// features.  B-Trees are generally more memory and cache efficient than
00021   /// binary trees, because they store multiple keys/values in each node.  This
00022   /// implements a key/value mapping from index to delta, and allows fast lookup
00023   /// on index.  However, an added (important) bonus is that it can also
00024   /// efficiently tell us the full accumulated delta for a specific file offset
00025   /// as well, without traversing the whole tree.
00026   class DeltaTree {
00027     void *Root;    // "DeltaTreeNode *"
00028     void operator=(const DeltaTree&); // DO NOT IMPLEMENT
00029   public:
00030     DeltaTree();
00031 
00032     // Note: Currently we only support copying when the RHS is empty.
00033     DeltaTree(const DeltaTree &RHS);
00034     ~DeltaTree();
00035 
00036     /// getDeltaAt - Return the accumulated delta at the specified file offset.
00037     /// This includes all insertions or delections that occurred *before* the
00038     /// specified file index.
00039     int getDeltaAt(unsigned FileIndex) const;
00040 
00041     /// AddDelta - When a change is made that shifts around the text buffer,
00042     /// this method is used to record that info.  It inserts a delta of 'Delta'
00043     /// into the current DeltaTree at offset FileIndex.
00044     void AddDelta(unsigned FileIndex, int Delta);
00045   };
00046 }  // end namespace clang
00047 
00048 #endif