Tools.h++ Manual
104011 Tandem Computers Incorporated 22-33
22
Program output:
April 12, 1975
Public constructors
RWTPtrHashDictionary<KV>(unsigned (*hashKey)(const K&),
size_t buckets = RWDEFAULT_CAPACITY);
Constructs an empty hash dictionary. The first argument is a pointer to a user-
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()
.
RWTPtrHashDictionary<KV>(const RWTPtrHashDictionary<KV>& c
);
Constructs a new hash dictionary as a shallow copy of
c
. After construction,
pointers will be shared between the two collections. The new object will use
the same hashing function and have the same number of buckets as
c
. Hence,
the keys will not be rehashed.
Public operators
RWTPtrHashDictionary<KV&
operator=(const RWTPtrHashDictionary<KV>& c);
Sets self to a shallow copy of
c
. Afterwards, pointers will be shared between
the two collections. Self will use the same hashing function and have the
number of buckets as
c
. Hence, the keys will not be rehashed.
V*& operator[](K* key);
Look up the key
key
and return a reference to the pointer of its associated
value. If the key is not in the dictionary, then it is added to the dictionary. In
this case, the pointer to the value will be undefined. Because of this, if there is
a possibility that a key will not be in the dictionary, then this operator can only
be used as an l-value.
Public member functions
void applyToKeyAndValue(void
(*applyFun)(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
(K* key, V*& value, void* d);