Tools.h++ Manual

22-96 104011 Tandem Computers Incorporated
22
If you wish this to be automatically done, then you can subclass from this class
and implement your own special
insert()
and
remove()
functions which
perform a
resize()
as necessary.
Example
Program output:
The table does contain Oregon
The table does not contain Oregon
#include <rw/tvhasht.h>
#include <rw/cstring.h>
#include <rw/rstream.h>
unsigned hashIt(const RWCString& str) {return str.hash();}
main()
{
RWTValHashTable<RWCString> table(hashIt);
table.insert("Alabama"); // NB: Type conversion occurs
table.insert("Pennsylvania");
table.insert("Oregon");
table.insert("Montana");
cout << "The table " <<
(table.contains("Oregon") ? "does " : "does not ") <<
"contain Oregon\n";
table.removeAll("Oregon");
cout << "The table " <<
(table.contains("Oregon") ? "does " : "does not ") <<
"contain Oregon";
return 0;
}