SourcePro C++ 12.0 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
Represents a dictionary for the storage and retrieval of key-value pairs, and implemented as a B-tree. More...
#include <rw/btrdict.h>
Dictionary class implemented as a B-tree, for the storage and retrieval of key-value pairs. Both the keys and values must inherit abstract base class RWCollectable. The elements are ordered internally according to the value returned by virtual function RWCollectable::compareTo() of the keys. Duplicate keys are not allowed.
The B-tree is balanced. That is, 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 result in shallower trees, but less efficient use of memory.
#include <rw/btrdict.h> RWBTreeDictionary a;
Polymorphic
RWBTreeDictionary::RWBTreeDictionary | ( | ) |
Constructs an empty B-tree dictionary.
RWBTreeDictionary::RWBTreeDictionary | ( | const RWBTreeDictionary & | btr | ) |
Constructs self as a shallow copy of btr.
RWBTreeDictionary::RWBTreeDictionary | ( | RWBTreeDictionary && | btr | ) | [inline] |
Move constructor. The constructed RWBTreeDictionary takes ownership of the data owned by btr.
virtual RWBTreeDictionary::~RWBTreeDictionary | ( | ) | [virtual] |
Calls clear().
void RWBTreeDictionary::applyToKeyAndValue | ( | RWapplyKeyAndValue | ap, | |
void * | ||||
) |
Applies the user-supplied function pointed to by ap to each key-value pair of the collection, in order, from smallest to largest.
static RWClassID RWBTreeDictionary::classIsA | ( | ) | [static] |
virtual void RWBTreeDictionary::clear | ( | ) | [virtual] |
Removes all key-value pairs from the collection.
Reimplemented from RWBTree.
virtual void RWBTreeDictionary::clearAndDestroy | ( | ) | [virtual] |
Removes all key-value pairs from the collection, and deletes both the key and the value.
Reimplemented from RWCollection.
virtual RWCollectable* RWBTreeDictionary::find | ( | const RWCollectable * | target | ) | const [virtual] |
RWCollectable* RWBTreeDictionary::findKeyAndValue | ( | const RWCollectable * | target, | |
RWCollectable *& | v | |||
) | const |
Returns the key in the collection that compares equal to the object pointed to by target, or rwnil if no key was found. The value is put in v. You are responsible for defining v before calling this function.
RWCollectable* RWBTreeDictionary::findValue | ( | const RWCollectable * | target, | |
RWCollectable * | newValue | |||
) | const |
Returns the value associated with the key that compares equal to the object pointed to by target, or rwnil if no key was found. Replaces the value with newValue (if a key was found).
RWCollectable* RWBTreeDictionary::findValue | ( | const RWCollectable * | target | ) | const |
Returns the value associated with the key that compares equal to the object pointed to by target, or rwnil if no key was found.
RWCollectable* RWBTreeDictionary::insertKeyAndValue | ( | RWCollectable * | key, | |
RWCollectable * | value | |||
) |
Adds a key-value pair to the collection and returns the key if successful, or rwnil if the key is already in the collection.
virtual RWClassID RWBTreeDictionary::isA | ( | ) | const [virtual] |
Returns __RWBTREEDICTIONARY
.
Reimplemented from RWBTree.
virtual bool RWBTreeDictionary::isEqual | ( | const RWCollectable * | t | ) | const [virtual] |
Returns true
if the collectable object "matches" the object at address t. The default definition is:
return this == t;
i.e., both objects have the same address (a test for identity). The definition may be redefined in any consistent way.
Reimplemented from RWBTree.
virtual RWCollectable* RWBTreeDictionary::newSpecies | ( | ) | const [virtual] |
Allocates a new object off the heap of the same type as self and returns a pointer to it. You are responsible for deleting the object when done with it.
Reimplemented from RWBTree.
bool RWBTreeDictionary::operator<= | ( | const RWBTreeDictionary & | btr | ) | const [inline] |
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. Normally this method is inherited from RWBTree.
void RWBTreeDictionary::operator= | ( | RWBTreeDictionary && | btr | ) | [inline] |
Move assignment. Self takes ownership of the data owned by btr.
void RWBTreeDictionary::operator= | ( | const RWBTreeDictionary & | btr | ) |
Sets self to a shallow copy of btr.
bool RWBTreeDictionary::operator== | ( | const RWBTreeDictionary & | 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 RWCollectable* RWBTreeDictionary::remove | ( | const RWCollectable * | target | ) | [virtual] |
virtual void RWBTreeDictionary::removeAndDestroy | ( | const RWCollectable * | target | ) | [virtual] |
Removes and deletes the key-value pair for which the key compares equal to the object pointed to by target. Note that both the key and the value are deleted. Does nothing if the key is not found.
Reimplemented from RWCollection.
RWCollectable* RWBTreeDictionary::removeKeyAndValue | ( | const RWCollectable * | target, | |
RWCollectable *& | v | |||
) |
Removes the key-value pair for which the key compares equal to the object pointed to by target. Returns the key, or rwnil if no match was found. The value is put in v. You are responsible for defining v before calling this function.
RWCollection* RWBTreeDictionary::select | ( | RWtestCollectablePair | testfunc, | |
void * | x | |||
) | const |
Evaluates the function pointed to by testfunc for both the key and the value of each item in the RWBTreeDictionary. It inserts keys and values for which the function returns true
into a new RWBTreeDictionary allocated off the heap and returns a pointer to this new collection. Because the new dictionary is allocated off the heap, you are responsible for deleting it when done. This is not a virtual function.
Reimplemented from RWCollection.
RWCollection* RWBTreeDictionary::select | ( | RWtestCollectable | testfunc, | |
void * | x | |||
) | const |
Evaluates the function pointed to by testfunc for the key of each item in the RWBTreeDictionary. It inserts keys and values for which the function returns true
into a new RWBTreeDictionary allocated off the heap and returns a pointer to this new collection. Because the new dictionary is allocated off the heap, you are responsible for deleting it when done. This is not a virtual function.
Reimplemented from RWCollection.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.