other versions
UHashTable(3U) | InterViews Reference Manual | UHashTable(3U) |
NAME¶
UHashTable, UHashElem - hash table classes
SYNOPSIS¶
#include <Unidraw/uhash.h>
DESCRIPTION¶
UHashTable implements a simple open hash table. The number of slotscan be specified when the table is created. UHashTable storesUHashElem instances, which contain the key that is hashed. Code thatuses UHashTables may derive from UHashElem to store data in additionto the key. UHashTable also provides operations for iterating overthe elements in the hash table.
UHASHELEMOPERATIONS¶
- UHashElem(void* = nil)
- Create a UHashElem with the given key value.
- void* GetKey()
- void SetKey(void*)
- Explicitly get and set the element's key value.
UHASHTABLEPUBLICOPERATIONS¶
- UHashTable(int nslots)
- Create a new UHashTable, specifying its number of slots.
- virtual void Register(void* key, UHashElem* = nil)
- Make an entry into the hash table. If no UHashElem is supplied, thisfunction call the CreateElem function (described below) to create one,and it will call SetKey (with key as its argument) on the result.
- virtual void Unregister(void* key)
- Remove the element with the matching key from the hash table anddelete it.
- void First(Iterator&)
- void Next(Iterator&)
- boolean Done(Iterator)
- UHashElem* GetElem(Iterator)
- Operations for iterating over the elements in the hash table. Theseoperation do not guarantee a particular ordering for the iteration.First initializes an iterator to point to the first element in thetraversal, Next increments the iterator to point to the followingelement, and Done returns whether or not the iterator points beyondthe last element in the traversal. GetElem returns the element towhich the given iterator points.
- UHashElem* Find(void* key)
- Find the element with the matching key (as defined by the Equaloperation, described below) in the hash table.
UHASHTABLEPROTECTEDOPERATIONS¶
- virtual UHashElem* CreateElem()
- Return a new UHashElem instance. Subclasses of UHashTable shouldredefine this function if they use subclasses of UHashElem.
- virtual int Hash(void* key)
- Hash the specified key to return a slot index. This value should beless than the value of the _nslots member variable.
- virtual boolean Equal(void* key1, void* key2)
- Return whether the specified keys are equivalent. By default, Equalsimply compares the pointers for equality. Subclasses may redefinethis operation to make more sophisticated comparisons.
SEEALSO¶
Iterator(3U)
3 October 1990 | Unidraw |