Tools.h++ Manual
104011 Tandem Computers Incorporated 21-123
21
Example
Program output:
Table contains 4 entries.
It does contain the key February 22, 1983
Public constructors
RWHashTable(size_t N = RWCollection::DEFAULT_CAPACITY);
Construct an empty hash table with
N
buckets.
RWHashTable(const RWHashTable& t);
Copy constructor. Create a new hash table as a shallow copy of the table
t
.
The new table will have the same number of buckets as the old table. Hence,
the members need not be and will not be rehashed.
#include <rw/hashtab.h>
#include <rw/colldate.h>
#include <rw/rstream.h>
main()
{
RWHashTable table;
table.insert(new Date(7, "July", 1990));
table.insert(new Date(1, "May", 1977));
table.insert(new Date(22, "Feb", 1983));
table.insert(new Date(2, "Aug", 1966));
cout << "Table contains " << table.entries() << " entries.\n";
Date key(22, "Feb", 1983);
cout << "It does ";
if (!table.contains(&key)) cout << "not ";
cout << "contain the key " << key << endl;
return 0;
}