In file ../include/EST_THash.h:

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

> An open hash table.

## Inheritance:

### Public Classes

  | Pair Iteration
  struct | IPointer_s A position in the table is given by a bucket number and a pointer into the bucket
  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
  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
  | Key Iteration
  struct | IPointer_k_s A position in the table is given by a bucket number and a pointer into the bucket
  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
  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

### Public Methods

  | EST_THash (int size, unsigned int (*hash_function)(const K &key, unsigned int size)= NULL) Create a table with the given number of buckets.
  | 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 Return the value associated with the key.
  V& | val (const K &key) const Return the value associated with the key
  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

### Inherited from EST_HashFunctions:

### Public Methods

static unsigned int DefaultHash(const void* data, size_t size, unsigned int n)
static unsigned int StringHash(const EST_String &key, unsigned int size)

## Documentation

> 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.

`EST_THash(int size, unsigned int (*hash_function)(const K &key, unsigned int size)= NULL)`
  Create a table with the given number of buckets. Optionally setting a custom hash function.

`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`
  Return the value associated with the key. <parameter>found</parameter> is set to whether such an entry was found.

`V& val(const K &key) const`
  Return the value associated with the key

`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.
  Friends:
    class EST_TStructIterator< EST_THash<K, V>, IPointer, EST_Hash_Pair<K, V> >
    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> >

  `struct IPointer_s`
    A position in the table is given by a bucket number and a pointer into the bucket

  `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

  `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

`Key Iteration`
  This iterator steps through the table returning just keys.
  Friends:
    class EST_TIterator< EST_THash<K, V>, IPointer_k, K >
    class EST_TRwIterator< EST_THash<K, V>, IPointer_k, K >

  `struct IPointer_k_s`
    A position in the table is given by a bucket number and a pointer into the bucket

  `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

  `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

Direct child classes:
  EST_TStringHash

Alphabetic index HTML hierarchy of classes or Java

This page is part of the Edinburgh Speech Tools Library documentation
Copyright University of Edinburgh 1997
Contact: speech_tools@cstr.ed.ac.uk