Tools.h++ Manual

104011 Tandem Computers Incorporated 22-43
22
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()
.
RWTPtrHashTable<T>(const RWTPtrHashTable<T>& c);
Constructs a new hash table as a shallow copy of
c
. After construction,
pointers will be shared between the two collections. The new object will have
the same number of buckets as
c
. Hence, the keys will not be rehashed.
Public operators
RWTPtrHashTable&<T>operator=(const RWTPtrHashTable<T>& c);
Sets self to a shallow copy of
c
. Afterwards, pointers will be shared between
the two collections and self will have the same number of buckets as
c
. Hence,
the keys will not be rehashed.
Public member functions
void apply(void (*applyFun)(T*,
void*), void* d);
Applies the user-defined function pointed to by
applyFun
to every item in the
table. This function must have prototype:
void
yourFun
(T* a, void* d);
Client data may be passed through as parameter
d
. The items should not be
changed in any way that could change their hash value.
void clear();
Removes all items from the collection.
void clearAndDestroy();
Removes all items from the collection and calls their destructors.
RWBoolean contains(T* p) const;
Returns
TRUE
if the collection contains an item which is equal to the item
pointed to by
p
. Returns
FALSE
otherwise. Equality is measured by the class-
defined equality operator for type
T
.
size_t entries() const;
Returns the number of items currently in the collection.