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

Maintains a list of names, where each name has a type and some contents. More...

#include <symbol_table.h>

Public Member Functions

 symbol_table (int estimated_elements=100)
 constructs a symbol table with sufficient size for "estimated_elements". More...
 
 symbol_table (const symbol_table< contents > &to_copy)
 
 ~symbol_table ()
 
int symbols () const
 returns the number of symbols listed in the table. More...
 
int estimated_elements () const
 returns the number of symbols the table is optimized for. More...
 
void rehash (int estimated_elements)
 resizes underlying table to support "estimated_elements". More...
 
void hash_appropriately (int estimated_elements)
 Resizes the number of table slots to have space for "estimated_elements". More...
 
symbol_tableoperator= (const symbol_table< contents > &to_copy)
 
basis::outcome add (const basis::astring &name, const contents &storage)
 Enters a symbol name into the table along with some contents. More...
 
const basis::astringname (int index) const
 returns the name held at the "index". More...
 
void names (string_set &to_fill) const
 returns the names of all the symbols currently held. More...
 
contents & operator[] (int index)
 provides access to the symbol_table's contents at the "index". More...
 
const contents & operator[] (int index) const
 provides a constant peek at the contents at the "index". More...
 
const contents & get (int index) const
 named equivalent for the bracket operator. More...
 
contents & use (int index)
 named equivalent for the bracket operator. More...
 
contents * find (const basis::astring &name) const
 returns the contents held for "name" or NULL_POINTER if it wasn't found. More...
 
contents * find (const basis::astring &name, basis::string_comparator_function *comparator) const
 Specialized search via a comparison method "comparator". More...
 
int dep_find (const basis::astring &name) const
 Searches for a symbol by its "name". More...
 
basis::outcome retrieve (int index, basis::astring &symbol_name, contents &contains) const
 Locates the symbol at position "index" and stores it to the parameters. More...
 
basis::outcome whack (const basis::astring &name)
 removes a symbol from the table. More...
 
basis::outcome zap_index (int index)
 zaps the entry at the specified index. slower than whack(). More...
 
void reset ()
 

Detailed Description

template<class contents>
class structures::symbol_table< contents >

Maintains a list of names, where each name has a type and some contents.

Definition at line 35 of file symbol_table.h.

Constructor & Destructor Documentation

◆ symbol_table() [1/2]

template<class contents >
structures::symbol_table< contents >::symbol_table ( int  estimated_elements = 100)

constructs a symbol table with sufficient size for "estimated_elements".

the "estimated_elements" dictates how large the symbol table's key space is. the number of keys that can be stored without collisions (assuming perfect distribution from the hash function) will be close to the number of elements specified.

Definition at line 206 of file symbol_table.h.

◆ symbol_table() [2/2]

template<class contents >
structures::symbol_table< contents >::symbol_table ( const symbol_table< contents > &  to_copy)

Definition at line 212 of file symbol_table.h.

◆ ~symbol_table()

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

Definition at line 219 of file symbol_table.h.

References basis::WHACK().

Member Function Documentation

◆ add()

template<class contents >
basis::outcome structures::symbol_table< contents >::add ( const basis::astring name,
const contents &  storage 
)

Enters a symbol name into the table along with some contents.

If the name already exists in the table, then the previous contents are replaced with these, but EXISTING is returned. If this is a new entry, then IS_NEW is returned instead.

Definition at line 383 of file symbol_table.h.

References structures::internal_symbol_info< contents >::_content.

Referenced by processes::configured_applications::add_program(), processes::configured_applications::add_startup_entry(), processes::configured_applications::configured_applications(), configuration::registry_configurator::get_section(), configuration::table_configurator::get_section(), configuration::variable_tokenizer::parse(), bookmark_tree::process_category(), and configuration::table_configurator::put().

◆ dep_find()

template<class contents >
int structures::symbol_table< contents >::dep_find ( const basis::astring name) const

Searches for a symbol by its "name".

Returns the index or NOT_FOUND. NOTE: this is deprecated; it is far faster to use the first find method above.

Definition at line 322 of file symbol_table.h.

◆ estimated_elements()

template<class contents >
int structures::symbol_table< contents >::estimated_elements

returns the number of symbols the table is optimized for.

Definition at line 226 of file symbol_table.h.

◆ find() [1/2]

◆ find() [2/2]

template<class contents >
contents * structures::symbol_table< contents >::find ( const basis::astring name,
basis::string_comparator_function comparator 
) const

Specialized search via a comparison method "comparator".

Searches for a symbol by its "name" but uses a special comparison function "comparator" to determine if the name is really equal. This method is by its nature slower than the main find method, since all buckets must be searched until a match is found. It is just intended to provide extensibility.

Definition at line 364 of file symbol_table.h.

References FUNCDEF, LOG, structures::pack(), and structures::sym_tab_finder_apply().

◆ get()

template<class contents >
const contents& structures::symbol_table< contents >::get ( int  index) const
inline

named equivalent for the bracket operator.

Definition at line 80 of file symbol_table.h.

References structures::symbol_table< contents >::operator[]().

◆ hash_appropriately()

template<class contents >
void structures::symbol_table< contents >::hash_appropriately ( int  estimated_elements)

Resizes the number of table slots to have space for "estimated_elements".

Definition at line 237 of file symbol_table.h.

◆ name()

◆ names()

template<class contents >
void structures::symbol_table< contents >::names ( string_set to_fill) const

◆ operator=()

template<class contents >
symbol_table< contents > & structures::symbol_table< contents >::operator= ( const symbol_table< contents > &  to_copy)

◆ operator[]() [1/2]

template<class contents >
contents & structures::symbol_table< contents >::operator[] ( int  index)

provides access to the symbol_table's contents at the "index".

Definition at line 304 of file symbol_table.h.

References structures::internal_symbol_info< contents >::_content, and bounds_return.

Referenced by structures::symbol_table< contents >::get(), and structures::symbol_table< contents >::use().

◆ operator[]() [2/2]

template<class contents >
const contents & structures::symbol_table< contents >::operator[] ( int  index) const

provides a constant peek at the contents at the "index".

Definition at line 295 of file symbol_table.h.

References structures::internal_symbol_info< contents >::_content, and bounds_return.

◆ rehash()

template<class contents >
void structures::symbol_table< contents >::rehash ( int  estimated_elements)

resizes underlying table to support "estimated_elements".

Definition at line 230 of file symbol_table.h.

◆ reset()

◆ retrieve()

template<class contents >
basis::outcome structures::symbol_table< contents >::retrieve ( int  index,
basis::astring symbol_name,
contents &  contains 
) const

Locates the symbol at position "index" and stores it to the parameters.

retrieve() accesses the "index"th symbol in the table and returns the held contents for it as well as its name. if the outcome is OKAY, then the returned information is valid. otherwise, the search failed.

Definition at line 423 of file symbol_table.h.

References structures::internal_symbol_info< contents >::_content, structures::internal_symbol_info< contents >::_name, and bounds_return.

◆ symbols()

◆ use()

template<class contents >
contents& structures::symbol_table< contents >::use ( int  index)
inline

named equivalent for the bracket operator.

Definition at line 82 of file symbol_table.h.

References structures::symbol_table< contents >::operator[]().

◆ whack()

template<class contents >
basis::outcome structures::symbol_table< contents >::whack ( const basis::astring name)

removes a symbol from the table.

this succeeds only if the symbol name is present in the table.

Definition at line 410 of file symbol_table.h.

Referenced by processes::configured_applications::add_program(), configuration::table_configurator::delete_entry(), processes::configured_applications::remove_program(), and processes::configured_applications::remove_startup_entry().

◆ zap_index()

template<class contents >
basis::outcome structures::symbol_table< contents >::zap_index ( int  index)

zaps the entry at the specified index. slower than whack().

Definition at line 403 of file symbol_table.h.


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