Tools.h++ Manual

104011 Tandem Computers Incorporated 22-87
22
defined hashing function for items of type
K
(the key). The table will initally
have
buckets
buckets although this can be changed with member function
resize()
.
RWTValHashDictionary<K,V>(const RWTValHashDictionary<K,V>&
dict);
Copy constructor. Constructs a new hash dictionary as a copy of
dict
. The
new dictionary will have the same number of buckets as the old table. Hence,
although the keys and values must be copied into the new table, the keys will
not be rehashed.
Public operators
RWTValHashDictionary<K,V>&
operator=(const RWTValHashDictionary<K,V>& dict);
Sets self to a copy of
dict
. Afterwards, the new table will have the same
number of buckets as the old table. Hence, although the keys and values must
be copied into the new table, the keys will not be rehashed.
V& operator[](const K& key);
Look up the key
key
and return its associated value as an lvalue reference. If
the key is not in the dictionary, then it is added to the dictionary. In this case,
the value associated with the key will be provided by the default constructor
for objects of type
V
.
Public member functions
void applyToKeyAndValue(void
(*applyFun)(const K&,V&,void*),
void* d);
Applies the user-defined function pointed to by
applyFun
to every key-value
pair in the dictionary. This function must have prototype:
void
yourFun
(const K& key, V& value, void* d);
The key will be passed by value and hence cannot be changed. The value will
be passed by reference and can be modified. Client data may be passed
through as parameter
d
.
void clear();
Removes all items from the collection.