Tools.h++ Class Reference

Table Of Contents
// Alternative syntax:
birthdays[new RWCString("Susan")] =
new RWDate(30, "June", 1955);
birthdays[new RWCString("Gene")] =
new RWDate(5, "Jan", 1981);
// Print a birthday:
RWCString key("John");
cout << *birthdays[&key] << endl;
birthdays.clearAndDestroy();
return 0;
}
Program output:
April 12, 1975
Public Constructors
RWTPtrHashDictionary<K,V>(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<K,V>(const RWTPtrHashDictionary<K,V>& 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<K,V>&
operator=(const RWTPtrHashDictionary<K,V>& 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 lvalue.