Tools.h++ Manual
104011 Tandem Computers Incorporated 22-31
22
RWTPtrHashDictionary<K,V>
Synopsis
#include <rw/tphdict.h>
unsigned hashFun(const K&);
RWTPtrHashDictionary<K,V> dictionary(hashFun);
Description
RWTPtrHashDictionary<KV> 
is a dictionary of keys of type 
K 
and values of 
type 
V
, implemented using a hash table. While duplicates of values are 
allowed, duplicates of keys are not.
It is a pointer based collection: pointers to the keys and values are copied in and 
out of the hash buckets.
Parameters 
K 
and 
V 
represent the type of the key and the type of the value, 
respectively, to be inserted into the table. These can be either classes or built in 
types. Class 
K 
must have
• well-defined equality semantics (
K::operator==(const K&)
).
Class 
V 
can be of any type.
A user-supplied hashing function for type 
K 
must be supplied to the 
constructor when creating a new table. If 
K 
is a Tools.h++ class, then this 
requirement is usually trivial because all Tools.h++ objects know how to return 
a hashing value. This function has prototype:
unsigned 
hFun
(const K& a);
and should return a suitable hash value for the object 
a
.
To find a value, the key is first hashed to determine in which bucket the key 
and value can be found. The bucket is then searched for an object that is equal 
(as determined by the equality operator) to the key.
The initial number of buckets in the table is set by the constructor. There is a 
default value. If the number of (key/value) pairs in the collection greatly 
exceeds the number of buckets then efficiency will sag because each bucket 










