Tools.h++ Manual
104011 Tandem Computers Incorporated 22-97
22
Public constructors
RWTValHashTable<T>(unsigned (*hashFun)(const T&),
size_t buckets =
RWDEFAULT_CAPACITY);
Constructs a new 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()
.
RWTValHashTable<T>(const RWTValHashTable<T>& table);
Constructs a new hash table as a copy of
table
. The new table will have the
same number of buckets as the old table. Hence, although objects must be
copied into the new table, they will not be hashed.
Public operators
RWTValHashTable& operator=(const
RWTValHashTable<T>&);
Sets self to a copy of
table
. Afterwards, the new table will have the same
number of buckets as the old table. Hence, although objects must be copied
into the new table, they will not be hashed.
Public member functions
void apply(void (*applyFun)(const 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
(const T& a, void* d);
Client data may be passed through as parameter
d
.
void clear();
Removes all items from the collection.
RWBoolean contains(const T& val) const;
Returns
TRUE
if the collection contains an item which is equal to
val
. Returns
FALSE
otherwise. Equality is measured by the class-defined equality operator.
size_t entries() const;
Returns the number of items currently in the collection.
RWBoolean find(const T& a, T& k) const;
Returns
TRUE
if the collection contains an item which is equal to
val
and puts
the matching object into
k
. Returns
FALSE
otherwise and leaves
k
untouched.
Equality is measured by the class-defined equality operator.