SourcePro® 2024.1 |
SourcePro® API Reference Guide |
Represents a group of ordered elements not accessible by an external key, and for which duplicates are not allowed. More...
#include <rw/btree.h>
Public Member Functions | |
RWBTree () | |
RWBTree (const RWBTree &btr) | |
RWBTree (RWBTree &&btr) | |
virtual | ~RWBTree () |
virtual void | apply (RWapplyCollectable ap, void *) |
virtual void | clear () |
virtual RWCollectable * | copy () const |
virtual size_t | entries () const |
virtual RWCollectable * | find (const RWCollectable *target) const |
unsigned | height () const |
virtual RWCollectable * | insert (RWCollectable *c) |
virtual RWClassID | isA () const |
virtual bool | isEmpty () const |
virtual bool | isEqual (const RWCollectable *a) const |
virtual RWConstIterator * | newConstIterator () const |
virtual RWIterator * | newIterator () |
virtual RWCollectable * | newSpecies () const |
virtual size_t | occurrencesOf (const RWCollectable *target) const |
bool | operator<= (const RWBTree &btr) const |
RWBTree & | operator= (const RWBTree &btr) |
RWBTree & | operator= (RWBTree &&btr) |
bool | operator== (const RWBTree &btr) const |
virtual RWCollectable * | remove (const RWCollectable *target) |
void | swap (RWBTree &btr) |
Public Member Functions inherited from RWCollection | |
virtual | ~RWCollection () |
RWBag | asBag () const |
RWBinaryTree | asBinaryTree () const |
RWOrdered | asOrderedCollection () const |
RWSet | asSet () const |
RWBinaryTree | asSortedCollection () const |
virtual RWspace | binaryStoreSize () const |
virtual void | clearAndDestroy () |
virtual bool | contains (const RWCollectable *target) const |
void | operator+= (const RWCollection &c) |
void | operator-= (const RWCollection &c) |
virtual void | removeAndDestroy (const RWCollectable *target) |
virtual void | restoreGuts (RWFile &) |
virtual void | restoreGuts (RWvistream &) |
virtual void | saveGuts (RWFile &) const |
virtual void | saveGuts (RWvostream &) const |
RWCollection * | select (RWtestCollectable tst, void *vp) const |
Public Member Functions inherited from RWCollectable | |
virtual | ~RWCollectable () |
virtual int | compareTo (const RWCollectable *) const |
virtual unsigned | hash () const |
RWspace | recursiveStoreSize () const |
RWStringID | stringID () const |
Static Public Member Functions | |
static RWClassID | classIsA () |
Static Public Member Functions inherited from RWCollectable | |
static RWClassID | classID (const RWStringID &name) |
static RWClassID | classIsA () |
static bool | isAtom (RWClassID id) |
static RWspace | nilStoreSize () |
Additional Inherited Members | |
Static Public Attributes inherited from RWCollection | |
static size_t | DEFAULT_CAPACITY |
Related Symbols inherited from RWCollection | |
typedef void(* | RWapplyCollectable) (RWCollectable *, void *) |
typedef bool(* | RWtestCollectable) (const RWCollectable *, const void *) |
typedef bool(* | RWtestCollectablePair) (const RWCollectable *, const RWCollectable *, const void *) |
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 RWCollectable::compareTo().
This class has certain advantages over class RWBinaryTree. First, the B-tree is automatically balanced. (With class RWBinaryTree, you must call member function RWBinaryTree::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 <rw/btree.h>
and recompiling. Larger values 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.
RWBTree::RWBTree | ( | ) |
Constructs an empty B-tree.
|
virtual |
Calls clear().
RWBTree::RWBTree | ( | const RWBTree & | btr | ) |
Constructs self as a shallow copy of btr.
RWBTree::RWBTree | ( | RWBTree && | btr | ) |
Move constructor. The constructed RWBTree takes ownership of the data owned by btr.
|
virtual |
Invokes the function pointer ap on each item in the collection, in order, from smallest to largest. This supplied function should not do anything to the items that could change the ordering of the collection.
Implements RWCollection.
|
virtual |
Removes all objects from the collection. Does not delete the objects themselves.
Implements RWCollection.
Reimplemented in RWBTreeDictionary.
|
virtual |
Returns a new, copy-constructed object of the same type as self. The caller is responsible for deleting the object.
Reimplemented from RWCollectable.
Reimplemented in RWBTreeDictionary.
|
virtual |
Returns the total number of items in the collection.
Implements RWCollection.
|
virtual |
The first item that compares equal to the object pointed to by target is returned or rwnil if no item is found.
Implements RWCollection.
Reimplemented in RWBTreeDictionary.
unsigned RWBTree::height | ( | ) | const |
Returns the height of the tree, defined as the number of nodes traversed while descending from the root node to an external (leaf) node.
|
virtual |
Inserts the item c into the collection and returns it. The item c is inserted according to the value returned by compareTo(). If an item is already in the collection that isEqual() to c, then the old item is returned and the new item is not inserted. Returns rwnil if the insertion was unsuccessful.
Implements RWCollection.
Reimplemented in RWBTreeDictionary.
|
virtual |
|
inlinevirtual |
Returns true
if the collection is empty, otherwise returns false
.
Implements RWCollection.
|
virtual |
Behaves as if compareTo(t) was invoked, returning true
if the result equals 0, false
otherwise.
Reimplemented from RWCollectable.
Reimplemented in RWBTreeDictionary.
|
inlinevirtual |
Returns rwnil
Implements RWCollection.
|
inlinevirtual |
Returns rwnil
Implements RWCollection.
|
virtual |
Returns a new, default-constructed object of the same type as self. The caller is responsible for deleting the object.
Reimplemented from RWCollectable.
Reimplemented in RWBTreeDictionary.
|
virtual |
Returns the number of items that compare equal to target. Since duplicates are not allowed, this function can only return 0 or 1.
Implements RWCollection.
bool RWBTree::operator<= | ( | const RWBTree & | btr | ) | const |
Returns true
if self is a subset of btr. That is, for every item in self, there must be an item in btr that compares equal.
Move assignment. Self takes ownership of the data owned by btr.
bool RWBTree::operator== | ( | const RWBTree & | btr | ) | const |
Returns true
if self and btr are equivalent. That is, they must have the same number of items and for every item in self, there must be an item in btr that compares equal.
|
virtual |
Removes and returns the first item that compares equal to the object pointed to by target. Returns rwnil if no item was found.
Implements RWCollection.
Reimplemented in RWBTreeDictionary.
void RWBTree::swap | ( | RWBTree & | btr | ) |
Swaps the data owned by self with the data owned by btr.
Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |