Tools.h++ Manual
104011 Tandem Computers Incorporated 21-35
21
RWBTree
RWBTree
|
RWCollection
|
RWCollectable
Synopsis
#include <rw/btree.h>
RWBTree a;
Description Class
RWBTree
represents a group of ordered elements, not accessible by an
external key. Duplicates are not allowed. An object stored by class
RWBTree
must inherit abstract base class
RWCollectable
—the elements are ordered
internally according to the value returned by virtual function
compareTo()
(see class
RWCollectable
).
This class has certain advantages over class
RWBinaryTree
. First, the
B-Tree
is automatically balanced. (With class
RWBinaryTree
, you must call member
function
balance()
explicitly to balance the tree.) Nodes are never allowed
to have less than a certain number of items (called the order). The default order
is 50, but may be changed by resetting the value of the static constant
"order"
in the header file
<btree.h>
and recompiling. Larger values will result in
shallower trees, but less efficient use of memory.
Because many keys are held in a single node, class
RWBTree
also tends to
fragment memory less.
Public constructor
RWBTree();
Construct an empty
B-Tree
.
RWBTree(const RWBTree& btr);
Construct self as a shallow copy of
btr
.
virtual ~RWBTree();
Redefined from
RWCollection
. Calls
clear()
.