Tools.h++ Manual
22-42 104011 Tandem Computers Incorporated
22
Example
Program output:
The table does contain Oregon
The table does not contain Oregon
Public constructors
RWTPtrHashTable<T>(unsigned (*hashFun)(const T&),
size_t buckets = RWDEFAULT_CAPACITY);
#include <rw/tphasht.h>
#include <rw/cstring.h>
#include <rw/rstream.h>
unsigned hashIt(const RWCString& str) {return str.hash();}
main()
{
RWTPtrHashTable<RWCString> table(hashIt);
table.insert(new RWCString("Alabama"));
table.insert(new RWCString("Pennsylvania"));
table.insert(new RWCString("Oregon"));
table.insert(new RWCString("Montana"));
RWCString key("Oregon");
cout << "The table " <<
(table.contains(&key) ? "does " : "does not ") <<
"contain Oregon\n";
table.removeAll(&key);
cout << "The table " <<
(table.contains(&key) ? "does " : "does not ") << "contain
Oregon";
return 0;
}