RWBTreeDictionaryRWBTreeRWCollectionRWCollectable
#include <rw/btrdict.h> RWBTreeDictionary a;
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 compareTo() of the key (see class RWCollectable). 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 will result in shallower trees, but less efficient use of memory.
Polymorphic
RWBTreeDictionary();
Constructs an empty B-tree dictionary.
RWBoolean operator<=(const RWBTreeDictionary& 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. This operator is not explicitly present unless you are compiling with an implementation of the C++ Standard Library. Normally it is inherited from RWBTree.
Note: If you inherit from RWBTreeDictionary in the presence of the C++ Standard Library, we recommend that you override this operator and explicitly forward the call. Overload resolution in C++ will choose the Standard Library provided global operators over inherited class members. These global definitions are not appropriate for set-like partial orderings.
void applyToKeyAndValue(RWapplyKeyAndValue ap,void*);
Redefined from class RWCollection. Applies the user-supplied function pointed to by ap to each key-value pair of the collection, in order, from smallest to largest.
RWBinaryTree asBinaryTree(); RWBag asBag() const; RWSet asSet() const; RWOrdered asOrderedCollection() const; RWBinaryTree asSortedCollection() const:
Converts the RWBTreeDictionary to an RWBag, RWSet, RWOrdered, or an RWBinaryTree. Note that since a dictionary contains pairs of keys and values, the result of this call will be a container holding RWCollectableAssociations. Note also that the return value is a copy of the data. This can be very expensive for large collections. Consider using operator+=() to insert each RWCollectableAssociation from this dictionary into a collection of your choice.
virtual RWspace binaryStoreSize() const;
Inherited from class RWCollection.
virtual void clear();
Redefined from class RWCollection. Removes all key-value pairs from the collection.
virtual void clearAndDestroy();
Redefined from class RWCollection. Removes all key-value pairs in the collection, and deletes both the key and the value.
virtual int compareTo(const RWCollectable* a) const;
Inherited from class RWCollectable.
virtual RWBoolean contains(const RWCollectable* target) const;
Inherited from class RWCollection.
virtual size_t entries() const;
Redefined from class RWCollection.
virtual RWCollectable* find(const RWCollectable* target) const;
Redefined from class RWCollection. Returns the key in the collection which compares equal to the object pointed to by target, or nil if no key is found.
RWCollectable* findKeyAndValue(const RWCollectable* target, RWCollectable*& v) const;
Returns the key in the collection which compares equal to the object pointed to by target, or nil if no key was found. The value is put in v. You are responsible for defining v before calling this function.
RWCollectable* findValue(const RWCollectable* target) const;
Returns the value associated with the key which compares equal to the object pointed to by target, or nil if no key was found.
RWCollectable* findValue(const RWCollectable* target, RWCollectable* newValue);
Returns the value associated with the key which compares equal to the object pointed to by target, or nil if no key was found. Replaces the value with newValue (if a key was found).
virtual unsigned hash() const;
Inherited from class RWCollectable.
unsigned height() const;
Inherited from class RWBTree.
RWCollectable* insertKeyAndValue(RWCollectable* key,RWCollectable* value);
Adds a key-value pair to the collection and returns the key if successful, nil if the key is already in the collection.
virtual RWClassID isA() const;
Redefined from class RWCollectable to return __RWBTREEDICTIONARY.
virtual RWBoolean isEmpty() const;
Inherited from class RWBTree.
virtual RWBoolean isEqual(const RWCollectable* a) const;
Inherited from class RWCollectable.
virtual size_t occurrencesOf(const RWCollectable* target) const;
Redefined from class RWCollection. Returns the number of keys that compare equal with target. Because duplicates are not allowed, this function can only return 0 or 1.
virtual RWCollectable* remove(const RWCollectable* target);
Redefined from class RWCollection. Removes the key and value pair for which the key compares equal to the object pointed to by target. Returns the key, or nil if no match was found.
virtual void removeAndDestroy(const RWCollectable* target);
Redefined from class RWCollection. Removes and deletes the key and 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.
RWCollectable* removeKeyAndValue(const RWCollectable* target, RWCollectable*& v);
Removes the key and value pair for which the key compares equal to the object pointed to by target. Returns the key, or nil if no match was found. The value is put in v. You are responsible for defining v before calling this function.
virtual void restoreGuts(RWvistream&); virtual void restoreGuts(RWFile&); virtual void saveGuts(RWvostream&) const; virtual void saveGuts(RWFile&) const;
Inherited from class RWCollection.
virtual RWCollection* select(RWtestCollectable testfunc, void* x) const;
Evaluates the function pointed to by tst 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.
virtual RWCollection* select(RWtestCollectablePair testfunc, void* x) const;
Evaluates the function pointed to by tst 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.
RWStringID stringID();
(acts virtual) Inherited from class RWCollectable.