SourcePro® 2024.1 |
SourcePro® API Reference Guide |
Represents a group of unordered values, accessible by external keys. More...
#include <rw/hashdict.h>
Friends | |
class | RWHashDictionaryIterator |
Additional Inherited Members | |
![]() | |
static RWClassID | classID (const RWStringID &name) |
static RWClassID | classIsA () |
static bool | isAtom (RWClassID id) |
static RWspace | nilStoreSize () |
![]() | |
static size_t | DEFAULT_CAPACITY |
![]() | |
typedef void(* | RWapplyCollectable) (RWCollectable *, void *) |
typedef bool(* | RWtestCollectable) (const RWCollectable *, const void *) |
typedef bool(* | RWtestCollectablePair) (const RWCollectable *, const RWCollectable *, const void *) |
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.
RWHashDictionary::RWHashDictionary | ( | ) |
Constructs an empty hashed dictionary using RWCollection::DEFAULT_CAPACITY hashing buckets.
RWHashDictionary::RWHashDictionary | ( | size_t | n | ) |
Constructs an empty hashed dictionary using n hashing buckets.
RWHashDictionary::RWHashDictionary | ( | const RWHashDictionary & | hd | ) |
Copy constructor. Makes a shallow copy of the collection hd.
|
inline |
Move constructor. The constructed RWHashDictionary takes ownership of the data owned by hd.
|
virtual |
Calls clear().
void RWHashDictionary::applyToKeyAndValue | ( | RWapplyKeyAndValue | ap, |
void * | x ) |
Invokes the function pointer ap on each key-value pair in the collection. Pairs are not visited in any particular order. An untyped argument may be passed to the ap function through x.
|
virtual |
Removes all key-value pairs in the collection.
Reimplemented from RWHashTable.
|
virtual |
Removes all key-value pairs in the collection, and deletes the key and the value.
Reimplemented from RWSet.
|
virtual |
Returns a new, copy-constructed object of the same type as self. The caller is responsible for deleting the object.
Reimplemented from RWSet.
Reimplemented in RWIdentityDictionary.
|
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 | ) | const |
RWCollectable * RWHashDictionary::findValue | ( | const RWCollectable * | target, |
RWCollectable * | newValue ) const |
|
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 RWSet.
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 |
|
virtual |
Behaves as if compareTo(t) was invoked, returning true
if the result equals 0, false
otherwise.
Reimplemented from RWSet.
Reimplemented in RWIdentityDictionary.
|
virtual |
Returns a const pointer to a dynamically allocated iterator for the collection.
Reimplemented from RWSet.
|
virtual |
Returns a dynamically allocated iterator for the collection.
Reimplemented from RWSet.
|
virtual |
Returns a new, default-constructed object of the same type as self. The caller is responsible for deleting the object.
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.
RWHashDictionary & RWHashDictionary::operator= | ( | const RWHashDictionary & | hd | ) |
Assignment operator. Makes a shallow copy of the collection hd.
|
inline |
Move assignment. Self takes ownership of the data owned by hd.
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 |
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 |
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 |
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.
|
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.
|
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.
Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |