Edinburgh Speech Tools  2.1-release
EST_THash< K, V > Class Template Reference

An open hash table. The number of buckets should be set to allow enough space that there are relatively few entries per bucket on average. More...

#include <include/EST_THash.h>

Inheritance diagram for EST_THash< K, V >:
Collaboration diagram for EST_THash< K, V >:

Classes

class  IPointer
 
class  IPointer_k
 

Public Member Functions

 EST_THash (int size, unsigned int(*hash_function)(const K &key, unsigned int size)=NULL)
 
 EST_THash (const EST_THash< K, V > &from)
 Create a copy. More...
 
 ~EST_THash (void)
 Destroy the table. More...
 
void clear (void)
 Empty the table. More...
 
unsigned int num_entries (void) const
 Return the total number of entries in the table. More...
 
int present (const K &key) const
 Does the key have an entry? More...
 
V & val (const K &key, int &found) const
 
V & val (const K &key) const
 Return the value associated with the key. More...
 
const K & key (const V &val, int &found) const
 
const K & key (const V &val) const
 
void copy (const EST_THash< K, V > &from)
 Copy all entries. More...
 
void map (void(*func)(K &, V &))
 Apply func to each entry in the table. More...
 
int add_item (const K &key, const V &value, int no_search=0)
 Add an entry to the table. More...
 
int remove_item (const K &rkey, int quiet=0)
 Remove an entry from the table. More...
 
EST_THash< K, V > & operator= (const EST_THash< K, V > &from)
 Assignment is a copy operation. More...
 
void dump (ostream &stream, int all=0)
 Print the table to stream in a human readable format. More...
 

Pair Iteration

This iterator steps through the table returning key-value pairs.

typedef EST_Hash_Pair< K, V > Entry
 An entry returned by the iterator is a key value pair. More...
 
typedef EST_TStructIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > > Entries
 Give the iterator a sensible name. More...
 
typedef EST_TRwStructIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > > RwEntries
 
class EST_TStructIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > >
 The iterator must be a friend to access this private interface. More...
 
class EST_TRwStructIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > >
 
class EST_TIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > >
 
class EST_TRwIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > >
 
void skip_blank (IPointer &ip) const
 Shift to point at something. More...
 
void point_to_first (IPointer &ip) const
 Go to start of the table. More...
 
void move_pointer_forwards (IPointer &ip) const
 Move pointer forwards, at the end of the bucket, move down. More...
 
bool points_to_something (const IPointer &ip) const
 We are at the end if the pointer ever becomes NULL. More...
 
EST_Hash_Pair< K, V > & points_at (const IPointer &ip)
 Return the contents of this entry. More...
 

Key Iteration

This iterator steps through the table returning just keys.

typedef K KeyEntry
 An entry returned by this iterator is just a key. More...
 
typedef EST_TIterator< EST_THash< K, V >, IPointer_k, K > KeyEntries
 Give the iterator a sensible name. More...
 
typedef EST_TRwIterator< EST_THash< K, V >, IPointer_k, K > KeyRwEntries
 
class EST_TIterator< EST_THash< K, V >, IPointer_k, K >
 The iterator must be a friend to access this private interface. More...
 
class EST_TRwIterator< EST_THash< K, V >, IPointer_k, K >
 
void skip_blank (IPointer_k &ip) const
 Shift to point at something. More...
 
void point_to_first (IPointer_k &ip) const
 Go to start of the table. More...
 
void move_pointer_forwards (IPointer_k &ip) const
 Move pointer forwards, at the end of the bucket, move down. More...
 
bool points_to_something (const IPointer_k &ip) const
 We are at the end if the pointer ever becomes NULL. More...
 
K & points_at (const IPointer_k &ip)
 Return the key of this entry. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from EST_HashFunctions
static unsigned int DefaultHash (const void *data, ssize_t size, unsigned int n)
 A generally useful hash function. More...
 
static unsigned int StringHash (const EST_String &key, unsigned int size)
 A hash function for strings. More...
 

Detailed Description

template<class K, class V>
class EST_THash< K, V >

An open hash table. The number of buckets should be set to allow enough space that there are relatively few entries per bucket on average.

Definition at line 69 of file EST_THash.h.

Member Typedef Documentation

template<class K, class V>
typedef EST_Hash_Pair<K, V> EST_THash< K, V >::Entry

An entry returned by the iterator is a key value pair.

Definition at line 229 of file EST_THash.h.

template<class K, class V>
typedef EST_TStructIterator< EST_THash<K, V>, IPointer, EST_Hash_Pair<K, V> > EST_THash< K, V >::Entries

Give the iterator a sensible name.

Definition at line 232 of file EST_THash.h.

template<class K, class V>
typedef EST_TRwStructIterator< EST_THash<K, V>, IPointer, EST_Hash_Pair<K, V> > EST_THash< K, V >::RwEntries

Definition at line 233 of file EST_THash.h.

template<class K, class V>
typedef K EST_THash< K, V >::KeyEntry

An entry returned by this iterator is just a key.

Definition at line 288 of file EST_THash.h.

template<class K, class V>
typedef EST_TIterator< EST_THash<K, V>, IPointer_k, K > EST_THash< K, V >::KeyEntries

Give the iterator a sensible name.

Definition at line 291 of file EST_THash.h.

template<class K, class V>
typedef EST_TRwIterator< EST_THash<K, V>, IPointer_k, K > EST_THash< K, V >::KeyRwEntries

Definition at line 292 of file EST_THash.h.

Constructor & Destructor Documentation

template<class K, class V >
EST_THash< K, V >::EST_THash ( int  size,
unsigned int(*)(const K &key, unsigned int size)  hash_function = NULL 
)

Create a table with the given number of buckets. Optionally setting a custom hash function.

Definition at line 45 of file EST_THash.cc.

template<class K, class V>
EST_THash< K, V >::EST_THash ( const EST_THash< K, V > &  from)

Create a copy.

Definition at line 59 of file EST_THash.cc.

template<class K , class V >
EST_THash< K, V >::~EST_THash ( void  )

Destroy the table.

Definition at line 85 of file EST_THash.cc.

Member Function Documentation

template<class K , class V >
void EST_THash< K, V >::clear ( void  )

Empty the table.

Definition at line 66 of file EST_THash.cc.

template<class K, class V>
unsigned int EST_THash< K, V >::num_entries ( void  ) const
inline

Return the total number of entries in the table.

Definition at line 139 of file EST_THash.h.

template<class K, class V >
int EST_THash< K, V >::present ( const K &  key) const

Does the key have an entry?

Definition at line 96 of file EST_THash.cc.

template<class K, class V >
V & EST_THash< K, V >::val ( const K &  key,
int found 
) const

Return the value associated with the key. found is set to whether such an entry was found.

Definition at line 114 of file EST_THash.cc.

template<class K, class V>
V& EST_THash< K, V >::val ( const K &  key) const
inline

Return the value associated with the key.

Definition at line 151 of file EST_THash.h.

template<class K , class V>
const K & EST_THash< K, V >::key ( const V &  val,
int found 
) const

Definition at line 136 of file EST_THash.cc.

template<class K, class V>
const K& EST_THash< K, V >::key ( const V &  val) const
inline

Definition at line 154 of file EST_THash.h.

template<class K, class V>
void EST_THash< K, V >::copy ( const EST_THash< K, V > &  from)

Copy all entries.

Definition at line 242 of file EST_THash.cc.

template<class K, class V>
void EST_THash< K, V >::map ( void(*)(K &, V &)  func)

Apply func to each entry in the table.

Definition at line 154 of file EST_THash.cc.

template<class K, class V>
int EST_THash< K, V >::add_item ( const K &  key,
const V &  value,
int  no_search = 0 
)

Add an entry to the table.

Definition at line 167 of file EST_THash.cc.

template<class K, class V >
int EST_THash< K, V >::remove_item ( const K &  rkey,
int  quiet = 0 
)

Remove an entry from the table.

Definition at line 195 of file EST_THash.cc.

template<class K, class V>
EST_THash< K, V > & EST_THash< K, V >::operator= ( const EST_THash< K, V > &  from)

Assignment is a copy operation.

Definition at line 221 of file EST_THash.cc.

template<class K , class V >
void EST_THash< K, V >::dump ( ostream &  stream,
int  all = 0 
)

Print the table to stream in a human readable format.

Definition at line 228 of file EST_THash.cc.

template<class K, class V>
void EST_THash< K, V >::skip_blank ( IPointer ip) const
inlineprotected

Shift to point at something.

Definition at line 197 of file EST_THash.h.

template<class K, class V>
void EST_THash< K, V >::point_to_first ( IPointer ip) const
inlineprotected

Go to start of the table.

Definition at line 204 of file EST_THash.h.

template<class K, class V>
void EST_THash< K, V >::move_pointer_forwards ( IPointer ip) const
inlineprotected

Move pointer forwards, at the end of the bucket, move down.

Definition at line 209 of file EST_THash.h.

template<class K, class V>
bool EST_THash< K, V >::points_to_something ( const IPointer ip) const
inlineprotected

We are at the end if the pointer ever becomes NULL.

Definition at line 216 of file EST_THash.h.

template<class K, class V>
EST_Hash_Pair<K, V>& EST_THash< K, V >::points_at ( const IPointer ip)
inlineprotected

Return the contents of this entry.

Definition at line 219 of file EST_THash.h.

template<class K, class V>
void EST_THash< K, V >::skip_blank ( IPointer_k ip) const
inlineprotected

Shift to point at something.

Definition at line 258 of file EST_THash.h.

template<class K, class V>
void EST_THash< K, V >::point_to_first ( IPointer_k ip) const
inlineprotected

Go to start of the table.

Definition at line 265 of file EST_THash.h.

template<class K, class V>
void EST_THash< K, V >::move_pointer_forwards ( IPointer_k ip) const
inlineprotected

Move pointer forwards, at the end of the bucket, move down.

Definition at line 270 of file EST_THash.h.

template<class K, class V>
bool EST_THash< K, V >::points_to_something ( const IPointer_k ip) const
inlineprotected

We are at the end if the pointer ever becomes NULL.

Definition at line 277 of file EST_THash.h.

template<class K, class V>
K& EST_THash< K, V >::points_at ( const IPointer_k ip)
inlineprotected

Return the key of this entry.

Definition at line 280 of file EST_THash.h.

Friends And Related Function Documentation

template<class K, class V>
friend class EST_TStructIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > >
friend

The iterator must be a friend to access this private interface.

Definition at line 222 of file EST_THash.h.

template<class K, class V>
friend class EST_TRwStructIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > >
friend

Definition at line 223 of file EST_THash.h.

template<class K, class V>
friend class EST_TIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > >
friend

Definition at line 224 of file EST_THash.h.

template<class K, class V>
friend class EST_TRwIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > >
friend

Definition at line 225 of file EST_THash.h.

template<class K, class V>
friend class EST_TIterator< EST_THash< K, V >, IPointer_k, K >
friend

The iterator must be a friend to access this private interface.

Definition at line 283 of file EST_THash.h.

template<class K, class V>
friend class EST_TRwIterator< EST_THash< K, V >, IPointer_k, K >
friend

Definition at line 284 of file EST_THash.h.


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