RWBTreeOnDisk
Class
RWBTreeOnDisk has been designed to manage a B-tree in a disk file. The class represents an ordered collection of associations of keys and values, where the ordering is determined internally by comparing keys. Given a key, a value can be retrieved. Duplicate keys are not allowed.
Keys are arrays of char. The key length is set by the constructor. The ordering in the B-tree is determined by comparing keys with an external function, which you can change.
The type of the values is:
typedef long RWstoredValue;
The values typically represent an offset to a location in a file where an object is stored. Given a key, you can find where an object is stored and retrieve it. As far as class
RWBTreeOnDisk is concerned, however, the value has no special meaning—it is up to you to interpret it.
The class
RWBTreeOnDisk uses class
RWFileManager to manage the allocation and deallocation of space for the nodes of the B-tree. You can use the same
RWFileManager to manage the space for the objects themselves if the B-tree and data are to be in the same file. Alternatively, you could use a different
RWFileManager, managing a different file, to store the B-tree and data in separate files.
The member functions associated with class
RWBTreeOnDisk are similar to those of the in-memory class
RWBTreeDictionary, except that keys are arrays of
char rather than
RWCollectables. There are member functions to add a key-value pair, remove a pair, replace a value associated with a key, query for information associated with a key, operate on all key-value pairs in order, return the number of entries in the tree, and determine if a key is contained in the tree.