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>

List of all members.

Public Member Functions

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

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

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.

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

Definition at line 212 of file symbol_table.h.

template<class contents >
structures::symbol_table< contents >::~symbol_table (  )  [inline]

Definition at line 219 of file symbol_table.h.

References basis::WHACK().


Member Function Documentation

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

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 octopi::key_repository::add(), processes::configured_applications::add_program(), processes::configured_applications::add_startup_entry(), processes::configured_applications::configured_applications(), configuration::table_configurator::get_section(), configuration::variable_tokenizer::parse(), bookmark_tree::process_category(), and configuration::table_configurator::put().

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

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.

References structures::symbol_table< contents >::symbols().

template<class contents >
int structures::symbol_table< contents >::estimated_elements (  )  const [inline]

returns the number of symbols the table is optimized for.

Definition at line 226 of file symbol_table.h.

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

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 structures::sym_tab_apply_data< contents >::_found, structures::sym_tab_apply_data< contents >::_scf, structures::sym_tab_apply_data< contents >::_to_find, structures::symbol_table< contents >::find(), FUNCDEF, LOG, structures::pack(), and structures::sym_tab_finder_apply().

template<class contents >
contents * structures::symbol_table< contents >::find ( const basis::astring name  )  const [inline]
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.

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

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

Definition at line 237 of file symbol_table.h.

References structures::symbol_table< contents >::rehash().

template<class contents >
const basis::astring & structures::symbol_table< contents >::name ( int  index  )  const [inline]
template<class contents >
void structures::symbol_table< contents >::names ( string_set to_fill  )  const [inline]
template<class contents>
symbol_table< contents > & structures::symbol_table< contents >::operator= ( const symbol_table< contents > &  to_copy  )  [inline]
template<class contents >
const contents & structures::symbol_table< contents >::operator[] ( int  index  )  const [inline]

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, bounds_return, and structures::symbol_table< contents >::symbols().

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

resizes underlying table to support "estimated_elements".

Definition at line 230 of file symbol_table.h.

Referenced by structures::symbol_table< contents >::hash_appropriately().

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

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, bounds_return, and structures::symbol_table< contents >::symbols().

template<class contents >
int structures::symbol_table< contents >::symbols (  )  const [inline]
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.

template<class contents >
basis::outcome structures::symbol_table< contents >::whack ( const basis::astring name  )  [inline]
template<class contents >
basis::outcome structures::symbol_table< contents >::zap_index ( int  index  )  [inline]

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

Definition at line 403 of file symbol_table.h.

References structures::symbol_table< contents >::name(), and structures::symbol_table< contents >::whack().


The documentation for this class was generated from the following file:
Generated on Sat Jan 28 04:26:00 2012 for hoople2 project by  doxygen 1.6.3