SourcePro® C++ 13.1 |
SourcePro® C++ API Reference Guide |
Product Documentation: 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>
Static Public Member Functions | |
static RWClassID | classIsA () |
Static Public Member Functions inherited from RWBTree | |
static RWClassID | classIsA () |
Additional Inherited Members | |
Static Public Attributes inherited from RWCollection | |
static size_t | DEFAULT_CAPACITY |
Related Functions inherited from RWCollection | |
typedef void(* | RWapplyCollectable )(RWCollectable *, void *) |
typedef bool(* | RWtestCollectable )(const RWCollectable *, const void *) |
typedef bool(* | RWtestCollectablePair )(const RWCollectable *, const RWCollectable *, const void *) |
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.
Polymorphic
RWBTreeDictionary::RWBTreeDictionary | ( | ) |
Constructs an empty B-tree dictionary.
RWBTreeDictionary::RWBTreeDictionary | ( | const RWBTreeDictionary & | btr | ) |
Constructs self as a shallow copy of btr.
|
inline |
Move constructor. The constructed RWBTreeDictionary takes ownership of the data owned by btr.
|
virtual |
Calls clear().
void RWBTreeDictionary::applyToKeyAndValue | ( | RWapplyKeyAndValue | ap, |
void * | |||
) |
Invokes the function pointer ap on each key-value pair in the collection, in order, from smallest to largest.
|
virtual |
Removes all key-value pairs from the collection.
Reimplemented from RWBTree.
|
virtual |
Removes all key-value pairs from the collection, and deletes both the key and the value.
Reimplemented from RWCollection.
|
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 | ) | 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::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::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 |
Returns __RWBTREEDICTIONARY
.
Reimplemented from RWBTree.
|
virtual |
Returns true
if the collectable object "matches" the object at address t. The default definition is:
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 |
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.
|
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.
RWBTreeDictionary& RWBTreeDictionary::operator= | ( | const RWBTreeDictionary & | btr | ) |
Sets self to a shallow copy of btr.
|
inline |
Move assignment. Self takes ownership of the data owned by 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 |
|
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 | ( | 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.
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.
Copyright © 2015 Rogue Wave Software, Inc. All Rights Reserved. |