golib
0.5
|
#include <gohashtable.h>
Public Member Functions | |
goHashTable (goUInt32 mod_value=511) | |
virtual | ~goHashTable () |
void | setModValue (goUInt32) |
void | setDefault (const O &d) |
Set the default return value. More... | |
void | clear () |
goUInt32 | getModValue () const |
O & | operator[] (const I &in) |
virtual void | add (const I &key, const O &value) |
virtual O | remove (const I &key) |
bool | fail () |
goArray< void * > & | getLists () |
Protected Member Functions | |
void | addEntry (goUInt32 table, void *entry) |
void | eraseLists () |
Erases all lists and resizes the table to zero. | |
Protected Attributes | |
bool | lastFailed |
goUInt32 | modValue |
goArray< void * > | theTable |
O | dummy |
Implementation of a simple hash table. You always have to check fail() before doing anything to the result of an operator[] call, if you don't, the code is likely to crash. If you do, it should be safe. The table index is calculated out of the last lb(modValue+1) bits of the key.
|
virtual |
|
virtual |
void goHashTable< I, O >::setDefault | ( | const O & | d | ) |
void goHashTable< I, O >::setModValue | ( | goUInt32 | i | ) |
Sets the hash mod value. Only call this once, before you do anything else with the hash table object. If you don't, or if you call it more than once, unexpected behaviour is the result. should always be something like (2^n-1).
i | Mod value. |