SourcePro C++ 12.0 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
Represents a group of unordered values, accessible by external keys. More...
#include <rw/hashdict.h>
An RWHashDictionary represents a group of unordered values, accessible by external keys. Duplicate keys are not allowed. RWHashDictionary is implemented as a hash table of associations of keys and values. Both the key and the value must inherit from the abstract base class RWCollectable, with a suitable definition of the virtual function hash() and isEqual() for the key.
This class corresponds to the Smalltalk class Dictionary.
typedef RWHashDictionary Dictionary; // Smalltalk typedef. #include <rw/hashdict.h> RWHashDictionary a ;
Polymorphic
RWHashDictionary::RWHashDictionary | ( | size_t | n = RWCollection::DEFAULT_CAPACITY |
) |
Constructs an empty hashed dictionary using n hashing buckets.
RWHashDictionary::RWHashDictionary | ( | const RWHashDictionary & | hd | ) |
Copy constructor. Makes a shallow copy of the collection hd.
RWHashDictionary::RWHashDictionary | ( | RWHashDictionary && | hd | ) | [inline] |
Move constructor. The constructed RWHashDictionary takes ownership of the data owned by hd.
virtual RWHashDictionary::~RWHashDictionary | ( | ) | [virtual] |
Calls clear().
void RWHashDictionary::applyToKeyAndValue | ( | RWapplyKeyAndValue | ap, | |
void * | x | |||
) |
Applies the user-supplied function pointed to by ap to each key-value pair of the collection. Items are not visited in any particular order. An untyped argument may be passed to the ap function through x.
static RWClassID RWHashDictionary::classIsA | ( | ) | [static] |
Returns the RWClassID of this class.
Reimplemented from RWSet.
Reimplemented in RWIdentityDictionary.
virtual void RWHashDictionary::clear | ( | ) | [virtual] |
Removes all key-value pairs in the collection.
Reimplemented from RWHashTable.
virtual void RWHashDictionary::clearAndDestroy | ( | ) | [virtual] |
Removes all key-value pairs in the collection, and deletes the key and the value.
Reimplemented from RWSet.
virtual RWCollectable* RWHashDictionary::find | ( | const RWCollectable * | target | ) | const [virtual] |
Returns the key which isEqual() to the object pointed to by target, or rwnil if no key was found.
Reimplemented from RWHashTable.
RWCollectable* RWHashDictionary::findKeyAndValue | ( | const RWCollectable * | target, | |
RWCollectable *& | v | |||
) | const |
RWCollectable* RWHashDictionary::findValue | ( | const RWCollectable * | target, | |
RWCollectable * | newValue | |||
) | const |
RWCollectable* RWHashDictionary::findValue | ( | const RWCollectable * | target | ) | const |
virtual RWCollectable* RWHashDictionary::insert | ( | RWCollectable * | c | ) | [inline, private, virtual] |
RWCollectable* RWHashDictionary::insertKeyAndValue | ( | RWCollectable * | key, | |
RWCollectable * | value | |||
) |
Adds a key-value pair to the collection and returns the key if successful, rwnil if the key is already in the collection.
virtual RWClassID RWHashDictionary::isA | ( | ) | const [virtual] |
virtual bool RWHashDictionary::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 RWSet.
Reimplemented in RWIdentityDictionary.
virtual RWConstIterator* RWHashDictionary::newConstIterator | ( | ) | const [virtual] |
Returns a const pointer to a dynamically allocated iterator for the collection.
Reimplemented from RWSet.
virtual RWIterator* RWHashDictionary::newIterator | ( | ) | [virtual] |
Returns a dynamically allocated iterator for the collection.
Reimplemented from RWSet.
virtual RWCollectable* RWHashDictionary::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 RWSet.
Reimplemented in RWIdentityDictionary.
bool RWHashDictionary::operator<= | ( | const RWHashTable & | t | ) | const |
Returns true
if self is a subset of t, that is, every element of self has a counterpart in t which isEqual().
Reimplemented from RWSet.
Reimplemented in RWIdentityDictionary.
bool RWHashDictionary::operator<= | ( | const RWSet & | h | ) | const |
Returns true
if self is a subset of h, that is, every element of self has a counterpart in h which isEqual().
Reimplemented from RWSet.
Reimplemented in RWIdentityDictionary.
bool RWHashDictionary::operator<= | ( | const RWHashDictionary & | hd | ) | const |
Returns true
if for every key-value pair in self, there is a corresponding key in hd that isEqual(). Their corresponding values must also be equal.
Reimplemented in RWIdentityDictionary.
void RWHashDictionary::operator= | ( | RWHashDictionary && | hd | ) | [inline] |
Move assignment. Self takes ownership of the data owned by hd.
void RWHashDictionary::operator= | ( | const RWHashDictionary & | hd | ) |
Assignment operator. Makes a shallow copy of the collection hd.
bool RWHashDictionary::operator== | ( | const RWHashTable & | t | ) | const |
Returns true
if self and t have the same number of elements and if for every key in self there is a corresponding key in t which isEqual().
Reimplemented from RWHashTable.
bool RWHashDictionary::operator== | ( | const RWHashDictionary & | hd | ) | const |
Returns true
if self and hd have the same number of entries and if for every key-value pair in self, there is a corresponding key in hd that isEqual(). Their corresponding values must also be equal.
virtual RWCollectable* RWHashDictionary::remove | ( | const RWCollectable * | target | ) | [virtual] |
Removes the key and value pair where the key isEqual() to the item pointed to by target. Returns the key, or rwnil if no match was found.
Reimplemented from RWHashTable.
virtual void RWHashDictionary::removeAndDestroy | ( | const RWCollectable * | target | ) | [virtual] |
Removes and deletes the key and value pair where the key isEqual() to the item 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* RWHashDictionary::removeKeyAndValue | ( | const RWCollectable * | target, | |
RWCollectable *& | v | |||
) |
virtual RWCollection* RWHashDictionary::select | ( | RWtestCollectablePair | testfunc, | |
void * | x | |||
) | const [virtual] |
Evaluates the function pointed to by testfunc for both the key and the value of each item in the RWHashDictionary. It inserts keys and values for which the function returns true
into a new RWHashDictionary 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 a virtual
function which hides the non-virtual function inherited from RWCollection.
Reimplemented from RWCollection.
virtual RWCollection* RWHashDictionary::select | ( | RWtestCollectable | tst, | |
void * | x | |||
) | const [virtual] |
Evaluates the function pointed to by tst for the key of each item in the RWHashDictionary. It inserts keys and values for which the function returns true
into a new RWHashDictionary 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 a virtual
function which hides the non-virtual function inherited from RWCollection.
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.