Tools.h++ Manual

104011 Tandem Computers Incorporated 11-1
Using Class RWBTreeOnDisk 11
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
chars
. The key length is set by the constructor. The
ordering in the B-Tree is determined by comparing keys with an external
function. You can change this function.
The type of the values is set by a typedef. By default, this is:
typedef long RWstoredValue;
Typically, the values represent an offset to a location in a file where an object is
stored. Hence, given a key, one can find where an object is stored and retrieve
it. However, as far as class
RWBTreeOnDisk
is concerned, the value has no
special meaning—it is up to you to interpret it.
This class uses class
RWFileManager
to manage the allocation and
deallocation of space for the nodes of the B-Tree. The same
RWFileManager
can also be used to manage the space for the objects themselves if the B-Tree
and data are to be in the same file. Alternatively, a different
RWFileManager
,
managing a different file, could be used if it is desirable to store the B-Tree and
data in separate files.
The member functions associated with class
RWBTreeOnDisk
are identical to
those of class
RWBTree
, which manages a B-Tree in memory, except that keys
are arrays of
chars
rather than
RWCollectable*
's. There are member