SourcePro® 2023.1 |
SourcePro® API Reference Guide |
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 () |
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 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.
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 |
Returns a new, copy-constructed object of the same type as self. The caller is responsible for deleting the object.
Reimplemented from RWBTree.
|
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).
|
virtual |
Adds a copy of the RWCollectableAssociation a to the collection and returns its key. If an item in the collection already has a key which isEqual() to a, then rwnil is returned and the item is not inserted.
Reimplemented from RWBTree.
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 |
Behaves as if compareTo(t) was invoked, returning true
if the result equals 0, false
otherwise.
Reimplemented from RWBTree.
|
virtual |
Returns a new, default-constructed object of the same type as self. The caller is responsible for deleting the object.
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.
|
virtual |
Repeatedly calls the global operator:
followed by insert(RWCollectable*) for each item in the collection.
Reimplemented from RWCollection.
|
virtual |
Repeatedly calls the global operator:
followed by insert(RWCollectable*) for each item in the collection.
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.
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 © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |