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. More...
#include <include/EST_THash.h>
Classes | |
class | IPointer |
class | IPointer_k |
Public Member Functions | |
EST_THash (int size, unsigned int(*hash_function)(const K &key, unsigned int size)=NULL) | |
EST_THash (const EST_THash< K, V > &from) | |
Create a copy. More... | |
~EST_THash (void) | |
Destroy the table. More... | |
void | clear (void) |
Empty the table. More... | |
unsigned int | num_entries (void) const |
Return the total number of entries in the table. More... | |
int | present (const K &key) const |
Does the key have an entry? More... | |
V & | val (const K &key, int &found) const |
V & | val (const K &key) const |
Return the value associated with the key. More... | |
const K & | key (const V &val, int &found) const |
const K & | key (const V &val) const |
void | copy (const EST_THash< K, V > &from) |
Copy all entries. More... | |
void | map (void(*func)(K &, V &)) |
Apply func to each entry in the table. More... | |
int | add_item (const K &key, const V &value, int no_search=0) |
Add an entry to the table. More... | |
int | remove_item (const K &rkey, int quiet=0) |
Remove an entry from the table. More... | |
EST_THash< K, V > & | operator= (const EST_THash< K, V > &from) |
Assignment is a copy operation. More... | |
void | dump (ostream &stream, int all=0) |
Print the table to stream in a human readable format. More... | |
Pair Iteration | |
This iterator steps through the table returning key-value pairs. | |
typedef EST_Hash_Pair< K, V > | Entry |
An entry returned by the iterator is a key value pair. More... | |
typedef EST_TStructIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > > | Entries |
Give the iterator a sensible name. More... | |
typedef EST_TRwStructIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > > | RwEntries |
class | EST_TStructIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > > |
The iterator must be a friend to access this private interface. More... | |
class | EST_TRwStructIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > > |
class | EST_TIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > > |
class | EST_TRwIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > > |
void | skip_blank (IPointer &ip) const |
Shift to point at something. More... | |
void | point_to_first (IPointer &ip) const |
Go to start of the table. More... | |
void | move_pointer_forwards (IPointer &ip) const |
Move pointer forwards, at the end of the bucket, move down. More... | |
bool | points_to_something (const IPointer &ip) const |
We are at the end if the pointer ever becomes NULL. More... | |
EST_Hash_Pair< K, V > & | points_at (const IPointer &ip) |
Return the contents of this entry. More... | |
Key Iteration | |
typedef K | KeyEntry |
An entry returned by this iterator is just a key. More... | |
typedef EST_TIterator< EST_THash< K, V >, IPointer_k, K > | KeyEntries |
Give the iterator a sensible name. More... | |
typedef EST_TRwIterator< EST_THash< K, V >, IPointer_k, K > | KeyRwEntries |
class | EST_TIterator< EST_THash< K, V >, IPointer_k, K > |
The iterator must be a friend to access this private interface. More... | |
class | EST_TRwIterator< EST_THash< K, V >, IPointer_k, K > |
void | skip_blank (IPointer_k &ip) const |
Shift to point at something. More... | |
void | point_to_first (IPointer_k &ip) const |
Go to start of the table. More... | |
void | move_pointer_forwards (IPointer_k &ip) const |
Move pointer forwards, at the end of the bucket, move down. More... | |
bool | points_to_something (const IPointer_k &ip) const |
We are at the end if the pointer ever becomes NULL. More... | |
K & | points_at (const IPointer_k &ip) |
Return the key of this entry. More... | |
Additional Inherited Members | |
Static Protected Member Functions inherited from EST_HashFunctions | |
static unsigned int | DefaultHash (const void *data, ssize_t size, unsigned int n) |
A generally useful hash function. More... | |
static unsigned int | StringHash (const EST_String &key, unsigned int size) |
A hash function for strings. More... | |
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.
Definition at line 69 of file EST_THash.h.
typedef EST_Hash_Pair<K, V> EST_THash< K, V >::Entry |
An entry returned by the iterator is a key value pair.
Definition at line 229 of file EST_THash.h.
typedef EST_TStructIterator< EST_THash<K, V>, IPointer, EST_Hash_Pair<K, V> > EST_THash< K, V >::Entries |
Give the iterator a sensible name.
Definition at line 232 of file EST_THash.h.
typedef EST_TRwStructIterator< EST_THash<K, V>, IPointer, EST_Hash_Pair<K, V> > EST_THash< K, V >::RwEntries |
Definition at line 233 of file EST_THash.h.
An entry returned by this iterator is just a key.
Definition at line 288 of file EST_THash.h.
typedef EST_TIterator< EST_THash<K, V>, IPointer_k, K > EST_THash< K, V >::KeyEntries |
Give the iterator a sensible name.
Definition at line 291 of file EST_THash.h.
typedef EST_TRwIterator< EST_THash<K, V>, IPointer_k, K > EST_THash< K, V >::KeyRwEntries |
Definition at line 292 of file EST_THash.h.
EST_THash< K, V >::EST_THash | ( | int | size, |
unsigned int(*)(const K &key, unsigned int size) | hash_function = NULL |
||
) |
Create a table with the given number of buckets. Optionally setting a custom hash function.
Definition at line 45 of file EST_THash.cc.
Create a copy.
Definition at line 59 of file EST_THash.cc.
Destroy the table.
Definition at line 85 of file EST_THash.cc.
void EST_THash< K, V >::clear | ( | void | ) |
Empty the table.
Definition at line 66 of file EST_THash.cc.
Return the total number of entries in the table.
Definition at line 139 of file EST_THash.h.
Does the key have an entry?
Definition at line 96 of file EST_THash.cc.
Return the value associated with the key. found
is set to whether such an entry was found.
Definition at line 114 of file EST_THash.cc.
|
inline |
Return the value associated with the key.
Definition at line 151 of file EST_THash.h.
Definition at line 136 of file EST_THash.cc.
|
inline |
Definition at line 154 of file EST_THash.h.
Copy all entries.
Definition at line 242 of file EST_THash.cc.
void EST_THash< K, V >::map | ( | void(*)(K &, V &) | func | ) |
Apply func
to each entry in the table.
Definition at line 154 of file EST_THash.cc.
int EST_THash< K, V >::add_item | ( | const K & | key, |
const V & | value, | ||
int | no_search = 0 |
||
) |
Add an entry to the table.
Definition at line 167 of file EST_THash.cc.
Remove an entry from the table.
Definition at line 195 of file EST_THash.cc.
EST_THash< K, V > & EST_THash< K, V >::operator= | ( | const EST_THash< K, V > & | from | ) |
Assignment is a copy operation.
Definition at line 221 of file EST_THash.cc.
Print the table to stream
in a human readable format.
Definition at line 228 of file EST_THash.cc.
|
inlineprotected |
Shift to point at something.
Definition at line 197 of file EST_THash.h.
|
inlineprotected |
Go to start of the table.
Definition at line 204 of file EST_THash.h.
|
inlineprotected |
Move pointer forwards, at the end of the bucket, move down.
Definition at line 209 of file EST_THash.h.
|
inlineprotected |
We are at the end if the pointer ever becomes NULL.
Definition at line 216 of file EST_THash.h.
|
inlineprotected |
Return the contents of this entry.
Definition at line 219 of file EST_THash.h.
|
inlineprotected |
Shift to point at something.
Definition at line 258 of file EST_THash.h.
|
inlineprotected |
Go to start of the table.
Definition at line 265 of file EST_THash.h.
|
inlineprotected |
Move pointer forwards, at the end of the bucket, move down.
Definition at line 270 of file EST_THash.h.
|
inlineprotected |
We are at the end if the pointer ever becomes NULL.
Definition at line 277 of file EST_THash.h.
|
inlineprotected |
Return the key of this entry.
Definition at line 280 of file EST_THash.h.
|
friend |
The iterator must be a friend to access this private interface.
Definition at line 222 of file EST_THash.h.
|
friend |
Definition at line 223 of file EST_THash.h.
|
friend |
Definition at line 224 of file EST_THash.h.
|
friend |
Definition at line 225 of file EST_THash.h.
|
friend |
The iterator must be a friend to access this private interface.
Definition at line 283 of file EST_THash.h.
|
friend |
Definition at line 284 of file EST_THash.h.