feisty meow concerns codebase
2.140
|
A hash table for storing integers. More...
#include <int_hash.h>
Public Types | |
typedef bool | apply_function(const int &key, contents ¤t, void *data_link) |
Public Types inherited from structures::hash_table< int, contents > | |
enum | outcomes |
typedef bool | apply_function(const int &key, contents ¤t, void *data_link) |
the "apply_function" is what a user of the "apply" method must supply. More... | |
Public Member Functions | |
int_hash (int max_bits) | |
~int_hash () | |
const int_set & | ids () const |
void | ids (int_set &ids) const |
provides the current list of valid identifiers. More... | |
basis::outcome | add (int key, contents *to_store) |
overrides base add() and ensures that the id list stays up to date. More... | |
contents * | acquire (int key) |
overrides base acquire() by ensuring that the ids stay up to date. More... | |
bool | zap (int key) |
overrides base zap() method plus keeps id list updated. More... | |
void | reset () |
overrides base reset() and ensures that the id list stays up to date. More... | |
void | apply (apply_function *to_apply, void *data_link) |
operates on every item in the int_hash table. More... | |
Public Member Functions inherited from structures::hash_table< int, contents > | |
hash_table (const hashing_algorithm &hasher, int estimated_elements) | |
Creates a table using the "hasher" that is ready to store "estimated_elements". More... | |
virtual | ~hash_table () |
destroys any objects left in the hash_table. More... | |
DEFINE_CLASS_NAME ("hash_table") | |
void | rehash (int estimated_elements) |
resizes the hashing structures to optimise for a new size of "estimated_elements". More... | |
int | elements () const |
the number of valid items we found by traversing the hash table. More... | |
int | estimated_elements () const |
returns the size of table we're optimized for. More... | |
basis::outcome | add (const int &key, contents *to_store) |
Stores "to_store" into the table given its "key" for hashing. More... | |
basis::outcome | add (int *key, contents *to_store, bool check_dupes=true) |
specialized add for a pre-existing pointer "key". More... | |
basis::outcome | fast_dangerous_add (const int &key, contents *to_store) |
Like the add method above, but doesn't check for duplicates. More... | |
bool | find (const int &key, contents *&item_found) const |
locates the item specified by the "key", if possible. More... | |
contents * | find (const int &key) const |
simplified form of above find() method. More... | |
contents * | acquire (const int &key) |
retrieves the contents held for "key" out of the table. More... | |
bool | zap (const int &key) |
removes the entry with the "key" specified. More... | |
void | reset () |
removes all entries in the table and returns it to a pristine state. More... | |
void | apply (apply_function *to_apply, void *data_link) |
Invokes the function "to_apply" on every entry in the table. More... | |
bool | verify () const |
returns true if the hash table is internally consistent. More... | |
internal_hash_array< int, contents > & | table_access () const |
special accessor for the copy_hash_table method only. More... | |
Public Member Functions inherited from basis::nameable | |
virtual const char * | class_name () const =0 |
Returns the bare name of this class as a constant character pointer. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from structures::hash_table< int, contents > | |
static int | calculate_num_slots (int estimated_elements) |
a helper method that lets us know what n is for how many 2^n slots we should have. More... | |
A hash table for storing integers.
Implements a hash table indexed on integers that maintains a separate set of identifiers for listing the items that are presently in the hash table. This slows down additions somewhat, but finds are not affected. The advantage of the separate index is that the apply() method is much faster.
Definition at line 35 of file int_hash.h.
typedef bool structures::int_hash< contents >::apply_function(const int &key, contents ¤t, void *data_link) |
Definition at line 54 of file int_hash.h.
structures::int_hash< contents >::int_hash | ( | int | max_bits | ) |
Definition at line 72 of file int_hash.h.
structures::int_hash< contents >::~int_hash |
Definition at line 78 of file int_hash.h.
References basis::WHACK().
contents * structures::int_hash< contents >::acquire | ( | int | key | ) |
overrides base acquire() by ensuring that the ids stay up to date.
Definition at line 95 of file int_hash.h.
References structures::hash_table< key_type, contents >::acquire().
basis::outcome structures::int_hash< contents >::add | ( | int | key, |
contents * | to_store | ||
) |
overrides base add() and ensures that the id list stays up to date.
Definition at line 88 of file int_hash.h.
References structures::hash_table< key_type, contents >::add().
void structures::int_hash< contents >::apply | ( | apply_function * | to_apply, |
void * | data_link | ||
) |
operates on every item in the int_hash table.
Definition at line 116 of file int_hash.h.
References structures::hash_table< key_type, contents >::find().
const int_set & structures::int_hash< contents >::ids |
Definition at line 82 of file int_hash.h.
void structures::int_hash< contents >::ids | ( | int_set & | ids | ) | const |
provides the current list of valid identifiers.
Definition at line 85 of file int_hash.h.
void structures::int_hash< contents >::reset |
overrides base reset() and ensures that the id list stays up to date.
Definition at line 109 of file int_hash.h.
References structures::hash_table< key_type, contents >::reset().
bool structures::int_hash< contents >::zap | ( | int | key | ) |
overrides base zap() method plus keeps id list updated.
Definition at line 102 of file int_hash.h.
References structures::hash_table< key_type, contents >::zap().