feisty meow concerns codebase  2.140
structures::pointer_hash< contents > Class Template Reference

A hash table for storing pointers. More...

#include <pointer_hash.h>

Inheritance diagram for structures::pointer_hash< contents >:
Collaboration diagram for structures::pointer_hash< contents >:

Public Types

typedef bool apply_function(const void *&key, contents &current, void *data_link)
 
- Public Types inherited from structures::hash_table< void *, contents >
enum  outcomes
 
typedef bool apply_function(const void * &key, contents &current, void *data_link)
 the "apply_function" is what a user of the "apply" method must supply. More...
 

Public Member Functions

 pointer_hash (int estimated_elements)
 
 ~pointer_hash ()
 
const pointer_setids () const
 
void ids (pointer_set &ids) const
 provides the current list of valid identifiers. More...
 
basis::outcome add (void *key, contents *to_store)
 overrides base add() and ensures that the id list stays up to date. More...
 
contents * acquire (void *key)
 overrides base acquire() by ensuring that the ids stay up to date. More...
 
bool zap (void *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 pointer_hash table. More...
 
- Public Member Functions inherited from structures::hash_table< void *, 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 void * &key, contents *to_store)
 Stores "to_store" into the table given its "key" for hashing. More...
 
basis::outcome add (void * *key, contents *to_store, bool check_dupes=true)
 specialized add for a pre-existing pointer "key". More...
 
basis::outcome fast_dangerous_add (const void * &key, contents *to_store)
 Like the add method above, but doesn't check for duplicates. More...
 
bool find (const void * &key, contents *&item_found) const
 locates the item specified by the "key", if possible. More...
 
contents * find (const void * &key) const
 simplified form of above find() method. More...
 
contents * acquire (const void * &key)
 retrieves the contents held for "key" out of the table. More...
 
bool zap (const void * &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< void *, 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< void *, 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...
 

Detailed Description

template<class contents>
class structures::pointer_hash< contents >

A hash table for storing pointers.

Implements a hash table indexed on pointer values that maintains a separate set to list 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 37 of file pointer_hash.h.

Member Typedef Documentation

◆ apply_function

template<class contents >
typedef bool structures::pointer_hash< contents >::apply_function(const void *&key, contents &current, void *data_link)

Definition at line 56 of file pointer_hash.h.

Constructor & Destructor Documentation

◆ pointer_hash()

template<class contents >
structures::pointer_hash< contents >::pointer_hash ( int  estimated_elements)

Definition at line 74 of file pointer_hash.h.

◆ ~pointer_hash()

template<class contents >
structures::pointer_hash< contents >::~pointer_hash

Definition at line 80 of file pointer_hash.h.

References basis::WHACK().

Member Function Documentation

◆ acquire()

template<class contents >
contents * structures::pointer_hash< contents >::acquire ( void *  key)

overrides base acquire() by ensuring that the ids stay up to date.

Definition at line 97 of file pointer_hash.h.

References structures::hash_table< key_type, contents >::acquire().

◆ add()

template<class contents >
basis::outcome structures::pointer_hash< contents >::add ( void *  key,
contents *  to_store 
)

overrides base add() and ensures that the id list stays up to date.

Definition at line 90 of file pointer_hash.h.

References structures::hash_table< key_type, contents >::add().

◆ apply()

template<class contents >
void structures::pointer_hash< contents >::apply ( apply_function to_apply,
void *  data_link 
)

operates on every item in the pointer_hash table.

Definition at line 118 of file pointer_hash.h.

References structures::hash_table< key_type, contents >::find().

◆ ids() [1/2]

template<class contents >
const pointer_set & structures::pointer_hash< contents >::ids

Definition at line 84 of file pointer_hash.h.

◆ ids() [2/2]

template<class contents >
void structures::pointer_hash< contents >::ids ( pointer_set ids) const

provides the current list of valid identifiers.

Definition at line 87 of file pointer_hash.h.

◆ reset()

template<class contents >
void structures::pointer_hash< contents >::reset

overrides base reset() and ensures that the id list stays up to date.

Definition at line 111 of file pointer_hash.h.

References structures::hash_table< key_type, contents >::reset().

◆ zap()

template<class contents >
bool structures::pointer_hash< contents >::zap ( void *  key)

overrides base zap() method plus keeps id list updated.

Definition at line 104 of file pointer_hash.h.

References structures::hash_table< key_type, contents >::zap().


The documentation for this class was generated from the following file: