Tools.h++ Class Reference

Table Of Contents
can be changed by calling member function resize(). This is relatively expensive because all of the keys must be rehashed.
If you wish for this to be done automatically, then you can subclass from this class and implement your own special insert() and
remove() functions which perform a resize() as necessary.
Persistence
None
Example
#include <rw/tphasht.h>
#include <rw/cstring.h>
#include <rw/rstream.h>
main() {
RWTPtrHashTable<RWCString> table(RWCString::hash);
RWCString *states[4] = { new RWCString("Alabama"),
new RWCString("Pennsylvania"),
new RWCString("Oregon"),
new RWCString("Montana") };
table.insert(states[0]);
table.insert(states[1]);
table.insert(states[2]);
table.insert(states[3]);
RWCString key("Oregon");
cout << "The table " <<
(table.contains(&key) ? "does " : "does not ") <<
"contain Oregon\n";
table.removeAll(&key);
cout << "Now the table " <<
(table.contains(&key) ? "does " : "does not ") <<
"contain Oregon";
delete states[0];
delete states[1];
delete states[2];
delete states[3];
return 0;
}
Program output
The table does contain Oregon
Now the table does not contain Oregon
Public Constructors
RWTPtrHashTable<T>(unsigned (*hashFun)(const T&),
size_t buckets = RWDEFAULT_CAPACITY);
Constructs an empty hash table. The first argument is a pointer to a user-defined
hashing function for items of type T. The table will initally have buckets buckets
although this can be changed with member function resize().