Edinburgh Speech Tools  2.4-release
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
EST_THash< K, V > Class Template Reference

#include <include/EST_THash.h>

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

Classes

struct  IPointer_k_s
 
struct  IPointer_s
 

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

Pair Iteration

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

typedef struct IPointer_s IPointer
 
typedef EST_Hash_Pair< K, V > Entry
 An entry returned by the iterator is a key value pair.
 
typedef EST_TStructIterator
< EST_THash< K, V >, IPointer,
EST_Hash_Pair< K, V > > 
Entries
 Give the iterator a sensible name.
 
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.
 
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.
 
void point_to_first (IPointer &ip) const
 Go to start of the table.
 
void move_pointer_forwards (IPointer &ip) const
 Move pointer forwards, at the end of the bucket, move down.
 
bool points_to_something (const IPointer &ip) const
 We are at the end if the pointer ever becomes NULL.
 
EST_Hash_Pair< K, V > & points_at (const IPointer &ip)
 Return the contents of this entry.
 

Key Iteration

This iterator steps through the table returning just keys.

typedef struct IPointer_k_s IPointer_k
 
typedef K KeyEntry
 An entry returned by this iterator is just a key.
 
typedef EST_TIterator
< EST_THash< K, V >
, IPointer_k, K > 
KeyEntries
 Give the iterator a sensible name.
 
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.
 
class EST_TRwIterator< EST_THash< K, V >, IPointer_k, K >
 
void skip_blank (IPointer_k &ip) const
 Shift to point at something.
 
void point_to_first (IPointer_k &ip) const
 Go to start of the table.
 
void move_pointer_forwards (IPointer_k &ip) const
 Move pointer forwards, at the end of the bucket, move down.
 
bool points_to_something (const IPointer_k &ip) const
 We are at the end if the pointer ever becomes NULL.
 
K & points_at (const IPointer_k &ip)
 Return the key of this entry.
 

Additional Inherited Members

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

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.

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.

Member Function Documentation

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

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

Definition at line 114 of file EST_THash.cc.


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