Hash Tables
class EST_HashFunctions{}
class EST_HashFunctions This is just a convinient place to put some useful hash functions
DefaultHash()
static unsigned int DefaultHash ( const void *data, size_t size, unsigned int n) A generally useful hash function.
StringHash()
static unsigned int StringHash ( const EST_String &key, unsigned int size) A hash function for strings.
class EST_Hash_Pair{}
template <class K, class V> class EST_Hash_Pair This class is used in hash tables to hold a key value pair. Not much to say beyond that.
class EST_THash{}
template <class K, class V> class EST_THash ( : protected EST_HashFunctions An open hash table. The number of buckets should be set to allow enough space that there are relatively few entries per bucket on average.
EST_THash()
EST_THash ( int size, unsigned int (*hash_function)(const K &key, unsigned int size)= NULL) Create a table with the given number of buckets. Optionally setting a custom hash function.
val()
V& val ( const K &key, int &found) const Return the value associated with the key. found is set to whether such an entry was found.
operator = ()
EST_THash <K,V> & operator = ( const EST_THash<K, V> &from) Assignment is a copy operation
Pair Iteration
This iterator steps through the table returning key-value pairs.
union IPointer_s{}
struct IPointer_s A position in the table is given by a bucket number and a pointer into the bucket
move_pointer_forwards()
void move_pointer_forwards ( IPointer &ip) const Move pointer forwards, at the end of the bucket, move down.
points_to_something()
bool points_to_something ( const IPointer &ip) const We are at the end if the pointer ever becomes NULL
V;
friend class EST_TStructIterator EST_THash K V IPointer EST_Hash_Pair K V The iterator must be a friend to access this private interface.
Entries;
typedef EST_TStructIterator < EST_THash<K, V>, IPointer, EST_Hash_Pair<K, V> > Entries Give the iterator a sensible name.
Key Iteration
This iterator steps through the table returning just keys.
union IPointer_k_s{}
struct IPointer_k_s A position in the table is given by a bucket number and a pointer into the bucket
move_pointer_forwards()
void move_pointer_forwards ( IPointer_k &ip) const Move pointer forwards, at the end of the bucket, move down.
points_to_something()
bool points_to_something ( const IPointer_k &ip) const We are at the end if the pointer ever becomes NULL
K;
friend class EST_TIterator EST_THash K V IPointer_k K The iterator must be a friend to access this private interface.
KeyEntries;
typedef EST_TIterator < EST_THash<K, V>, IPointer_k, K > KeyEntries Give the iterator a sensible name.
class EST_TStringHash{}
template <class V> class EST_TStringHash ( : public EST_THash<EST_String, V> A specialised hash table for when the key is an EST_String.
This is just a version of EST_THash which has a different default hash function.
Entry;
typedef EST_Hash_Pair <EST_String, V> Entry An entry returned by the iterator is a key value pair.
Entries;
typedef EST_TStructIterator < EST_THash<EST_String, V>, IPointer, EST_Hash_Pair<EST_String, V> > Entries Give the iterator a sensible name.