#include <symtab.h>
Public Types | |
typedef void(* | callback_t )(const symtab_ty *stp, const nstring &key, void *data, void *arg) |
typedef void(* | reaper_t )(void *) |
Public Member Functions | |
~symtab_ty () | |
symtab_ty (int suggested_size=5) | |
size_t | size () const |
bool | empty () const |
void | clear (void) |
void * | query (string_ty *key) const |
void * | query (const nstring &key) const |
void * | query (const nstring_list &keys) const |
string_ty * | query_fuzzy (string_ty *key) const |
nstring | query_fuzzy (const nstring &key) const |
void | assign (string_ty *key, void *value) |
void | assign (const nstring &key, void *value) |
void | assign_push (string_ty *key, void *value) |
void | assign_push (const nstring &key, void *value) |
void | remove (string_ty *key) |
void | remove (const nstring &key) |
void | dump (const char *caption) const |
void | keys (string_list_ty *result) const |
void | keys (nstring_list &result) const |
void | walk (callback_t func, void *arg) const |
void | set_reap (reaper_t func) |
bool | valid () const |
Private Member Functions | |
void | split (void) |
symtab_ty (const symtab_ty &) | |
symtab_ty & | operator= (const symtab_ty &) |
Private Attributes | |
reaper_t | reap |
row_t ** | hash_table |
str_hash_ty | hash_modulus |
str_hash_ty | hash_mask |
str_hash_ty | hash_load |
Friends | |
class | symtab_iterator |
Data Structures | |
struct | row_t |
Definition at line 40 of file symtab.h.
typedef void(* symtab_ty::callback_t)(const symtab_ty *stp, const nstring &key, void *data, void *arg) |
typedef void(* symtab_ty::reaper_t)(void *) |
symtab_ty::~symtab_ty | ( | ) |
The destructor.
symtab_ty::symtab_ty | ( | int | suggested_size = 5 |
) |
The constructor.
suggested_size | You are able to suggest how many rows will be in the table. It is better to under estimate than overestimate and waste memory. Optimal resizing happens automagically. |
symtab_ty::symtab_ty | ( | const symtab_ty & | ) | [private] |
The copy constructor. Do not use.
size_t symtab_ty::size | ( | ) | const [inline] |
bool symtab_ty::empty | ( | ) | const [inline] |
void symtab_ty::clear | ( | void | ) |
The clear method may be used to discard all rows of the symbol table. It is not an error if the symbol table is already empty.
void* symtab_ty::query | ( | string_ty * | key | ) | const |
The query method may be used to search for a variable.
key | The row name to search for. |
void* symtab_ty::query | ( | const nstring & | key | ) | const |
The query method may be used to search for a variable.
key | The row name to search for. |
void* symtab_ty::query | ( | const nstring_list & | keys | ) | const |
The query method may be used to search for a variable.
keys | The row names to search for. The first found will be returned. |
The query_fuzzy method may be used to search for a variable.
key | The row name to search for. |
The query_fuzzy method may be used to search for a variable.
key | The row name to search for. |
void symtab_ty::assign | ( | string_ty * | key, | |
void * | value | |||
) |
The assign method is used to assign a value to a given variable.
key | They key (usually a variable name or simialar). | |
value | The value to be assigned to that name. |
If there is already a key of that name, the old data will be discarded, via the reap function, if one has been supplied.
This method has O(1) execution time. This method will eventually be DEPRECATED
void symtab_ty::assign | ( | const nstring & | key, | |
void * | value | |||
) |
The assign method is used to assign a value to a given variable.
key | They key (usually a variable name or simialar). | |
value | The value to be assigned to that name. |
If there is already a key of that name, the old data will be discarded, via the reap function, if one has been supplied.
This method has O(1) execution time.
void symtab_ty::assign_push | ( | string_ty * | key, | |
void * | value | |||
) |
The assign_push function is used to assign a value to a given variable. Any previous value will be obscured until this one is removed with the remove method.
key | They key (usually a variable name or simialar). | |
value | The value to be assigned to that name. |
This method has O(1) execution time. This method will eventually be DEPRECATED
void symtab_ty::assign_push | ( | const nstring & | key, | |
void * | value | |||
) |
The assign_push function is used to assign a value to a given variable. Any previous value will be obscured until this one is removed with the remove method.
key | They key (usually a variable name or simialar). | |
value | The value to be assigned to that name. |
This method has O(1) execution time.
void symtab_ty::remove | ( | string_ty * | key | ) |
The remove method is used to remove a variable from the symbol table.
key | The name of the row to be removed. |
This method has O(1) execution time. This method will eventually be DEPRECATED
void symtab_ty::remove | ( | const nstring & | key | ) |
The remove method is used to remove a variable from the symbol table.
key | The name of the row to be removed. |
This method has O(1) execution time.
void symtab_ty::dump | ( | const char * | caption | ) | const |
The dump method is used to dump the contents of the symbol table.
caption | The caption will be used to indicate why the symbol table was dumped. |
This method has O(n) execution time.
void symtab_ty::keys | ( | string_list_ty * | result | ) | const |
The keys method may be used to extract the list of row names from the symbol table.
result | Where to put the row names. It is cleared before any row names are placed in it. It is not sorted. |
This method has O(n) execution time. This method will eventually be DEPRECATED
void symtab_ty::keys | ( | nstring_list & | result | ) | const |
The keys method may be used to extract the list of row names from the symbol table.
result | Where to put the row names. It is cleared before any row names are placed in it. It is not sorted. |
This method has O(n) execution time.
void symtab_ty::walk | ( | callback_t | func, | |
void * | arg | |||
) | const |
The walk method is used to invoke a func tion for every row of the symbol table.
func | A pointer to the function to be called. | |
arg | An extra argument passed to the function. |
void symtab_ty::set_reap | ( | reaper_t | func | ) | [inline] |
bool symtab_ty::valid | ( | ) | const |
The valid method determines whether the symbol table's internal values are self consistent. Usually only used for debugging.
void symtab_ty::split | ( | void | ) | [private] |
The split method is used to double the number of buckets in the symbol table, which results in halving the load. The symbols are then redistributed into the new buckets.
The probablity of another split thus halves every time this method is called, resulting in overall O(1) behaviour because (sigma(2 ** -n) == 1).
The assignment operator. Do not use.
friend class symtab_iterator [friend] |
reaper_t symtab_ty::reap [private] |
row_t** symtab_ty::hash_table [private] |
str_hash_ty symtab_ty::hash_modulus [private] |
str_hash_ty symtab_ty::hash_mask [private] |
str_hash_ty symtab_ty::hash_load [private] |