Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

HashTable Class Template Reference

Hash tabel class. More...

#include <HashTable.h>

List of all members.

Public Types

typedef HashTable<K,E,H> table_type
typedef H hash_type
typedef TableEntry<K, E> value_type
typedef std::list< value_typecontainer_type
typedef container_type::iterator iterator
typedef container_type::const_iterator const_iterator

Public Methods

 HashTable (int length = 16, int incr = 2)
 Standard constructor. More...

virtual ~HashTable ()
 Stabdard Destructor. More...

iterator begin ()
 Start of list iterator over table. More...

const_iterator begin () const
 Start of list iterator over table (CONST). More...

iterator end ()
 End of list iterator over table. More...

const_iterator end () const
 End of list iterator over table (CONST). More...

void clear ()
 Clear entire content. More...

long size () const
 Access size of the hash table (actual number of entries). More...

void reserve (int len)
 Reserve space for hashtable. More...

bool insert (const K& first, const E& second)
 Insert element identified by key. More...

value_typefind (const K& first)
 Retrieve element by key. More...

const value_typefind (const K& first) const
 Retrieve element by key (CONST). More...

void remove (const K& first)
 Remove element from table. More...


Protected Methods

void rehash (int new_size)
 rehash the entire table on growth. More...

value_typefind (size_t idx, const K& key )
 Retrieve element by key. More...

void remove (value_type* e)

Protected Attributes

int m_size
 Current table size. More...

int m_incr
 Increment factor on growth. More...

std::vector<value_type*> m_vec
 Vector with pointer to entries. More...

container_type m_con
 List with stored table objects. More...

hash_type m_hash
 Hash object. More...


Detailed Description

template<class K, class E, class H = HashTableHasher< K >> template class HashTable

Hash tabel class.

Description: Hash table which allows to access objects through a hash key. The table automatically rehashes if the table grows. The table is NOT optimized for element removal - this is very slow, because it requires hopping through a list.

Note: Use rather hash tables than STL maps. STL maps do not work with sharable images, because these stupid guys have allocated static storage on the implementation of binary trees......

History :

    +---------+----------------------------------------------+--------+
    |    Date |                 Comment                      | Who    |
    +---------+----------------------------------------------+--------+
    | 30/01/00| Initial version.                             | MF     |
    +---------+----------------------------------------------+--------+
    
Author: M.Frank Version: 1.0

Definition at line 43 of file HashTable.h.


Member Typedef Documentation

template<classK, classE, classH = HashTableHasher< K >>
typedef container_type::const_iterator HashTable<K, E, H>::const_iterator
 

Definition at line 86 of file HashTable.h.

template<classK, classE, classH = HashTableHasher< K >>
typedef std::list< value_type > HashTable<K, E, H>::container_type
 

Definition at line 84 of file HashTable.h.

template<classK, classE, classH = HashTableHasher< K >>
typedef H HashTable<K, E, H>::hash_type
 

Definition at line 82 of file HashTable.h.

template<classK, classE, classH = HashTableHasher< K >>
typedef container_type::iterator HashTable<K, E, H>::iterator
 

Definition at line 85 of file HashTable.h.

template<classK, classE, classH = HashTableHasher< K >>
typedef HashTable<K,E,H> HashTable<K, E, H>::table_type
 

Definition at line 81 of file HashTable.h.

template<classK, classE, classH = HashTableHasher< K >>
typedef TableEntry<K, E> HashTable<K, E, H>::value_type
 

Definition at line 83 of file HashTable.h.


Constructor & Destructor Documentation

template<classK, classE, classH = HashTableHasher< K >>
HashTable<K, E, H>::HashTable<K, E, H> ( int length = 16,
int incr = 2 ) [inline]
 

Standard constructor.

Definition at line 124 of file HashTable.h.

template<classK, classE, classH = HashTableHasher< K >>
HashTable<K, E, H>::~HashTable<K, E, H> ( ) [inline, virtual]
 

Stabdard Destructor.

Definition at line 128 of file HashTable.h.


Member Function Documentation

template<classK, classE, classH = HashTableHasher< K >>
const_iterator HashTable<K, E, H>::begin ( ) const [inline]
 

Start of list iterator over table (CONST).

Definition at line 136 of file HashTable.h.

template<classK, classE, classH = HashTableHasher< K >>
iterator HashTable<K, E, H>::begin ( ) [inline]
 

Start of list iterator over table.

Definition at line 132 of file HashTable.h.

Referenced by RefTableBase::begin(), and RefTableBase::serialize().

template<classK, classE, classH = HashTableHasher< K >>
void HashTable<K, E, H>::clear ( ) [inline]
 

Clear entire content.

Definition at line 148 of file HashTable.h.

Referenced by RefTableBase::clear().

template<classK, classE, classH = HashTableHasher< K >>
const_iterator HashTable<K, E, H>::end ( ) const [inline]
 

End of list iterator over table (CONST).

Definition at line 144 of file HashTable.h.

template<classK, classE, classH = HashTableHasher< K >>
iterator HashTable<K, E, H>::end ( ) [inline]
 

End of list iterator over table.

Definition at line 140 of file HashTable.h.

Referenced by RefTableBase::end(), RefTableBase::i_reference(), and RefTableBase::serialize().

template<classK, classE, classH = HashTableHasher< K >>
const value_type * HashTable<K, E, H>::find ( const K & first ) const [inline]
 

Retrieve element by key (CONST).

Definition at line 180 of file HashTable.h.

template<classK, classE, classH = HashTableHasher< K >>
value_type * HashTable<K, E, H>::find ( const K & first ) [inline]
 

Retrieve element by key.

Definition at line 176 of file HashTable.h.

template<classK, classE, classH = HashTableHasher< K >>
value_type * HashTable<K, E, H>::find ( size_t idx,
const K & key ) [inline, protected]
 

Retrieve element by key.

Definition at line 110 of file HashTable.h.

Referenced by find(), and RefTableBase::i_reference().

template<classK, classE, classH = HashTableHasher< K >>
bool HashTable<K, E, H>::insert ( const K & first,
const E & second ) [inline]
 

Insert element identified by key.

Definition at line 161 of file HashTable.h.

Referenced by RefTableBase::insertMapElement().

template<classK, classE, classH = HashTableHasher< K >>
void HashTable<K, E, H>::rehash ( int new_size ) [inline, protected]
 

rehash the entire table on growth.

Definition at line 100 of file HashTable.h.

template<classK, classE, classH = HashTableHasher< K >>
void HashTable<K, E, H>::remove ( const K & first ) [inline]
 

Remove element from table.

Definition at line 185 of file HashTable.h.

template<classK, classE, classH = HashTableHasher< K >>
void HashTable<K, E, H>::remove ( value_type * e ) [inline, protected]
 

Definition at line 118 of file HashTable.h.

template<classK, classE, classH = HashTableHasher< K >>
void HashTable<K, E, H>::reserve ( int len ) [inline]
 

Reserve space for hashtable.

Definition at line 157 of file HashTable.h.

Referenced by RefTableBase::reserve(), and RefTableBase::serialize().

template<classK, classE, classH = HashTableHasher< K >>
long HashTable<K, E, H>::size ( ) const [inline]
 

Access size of the hash table (actual number of entries).

Definition at line 153 of file HashTable.h.

Referenced by RefTableBase::serialize(), and RefTableBase::size().


Member Data Documentation

template<classK, classE, classH = HashTableHasher< K >>
container_type HashTable<K, E, H>::m_con [protected]
 

List with stored table objects.

Definition at line 95 of file HashTable.h.

template<classK, classE, classH = HashTableHasher< K >>
hash_type HashTable<K, E, H>::m_hash [protected]
 

Hash object.

Definition at line 97 of file HashTable.h.

template<classK, classE, classH = HashTableHasher< K >>
int HashTable<K, E, H>::m_incr [protected]
 

Increment factor on growth.

Definition at line 91 of file HashTable.h.

template<classK, classE, classH = HashTableHasher< K >>
int HashTable<K, E, H>::m_size [protected]
 

Current table size.

Definition at line 89 of file HashTable.h.

template<classK, classE, classH = HashTableHasher< K >>
std::vector< value_type *> HashTable<K, E, H>::m_vec [protected]
 

Vector with pointer to entries.

Definition at line 93 of file HashTable.h.


The documentation for this class was generated from the following file:
Generated at Wed Nov 21 12:22:10 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000