In file ../include/EST_THash.h:

template<class K, class V> class EST_THash

An open hash table.

Inheritance:


Public Classes

[more] Pair Iteration

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

[more]struct IPointer_k_s
A position in the table is given by a bucket number and a pointer into the bucket
[more]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]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

Public Methods

[more] EST_THash (int size, unsigned int (*hash_function)(const K &key, unsigned int size)= NULL)
Create a table with the given number of buckets.
[more] 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
Return the value associated with the key.
[more]V& val (const K &key) const
Return the value associated with the key
[more]void copy (const EST_THash<K, V> &from)
Copy all entries
[more]void map (void (*func)(K&, V&))
Apply <parameter>func</parameter> 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 <parameter>stream</parameter> in a human readable format


Inherited from EST_HashFunctions:

Public Methods

ostatic unsigned int DefaultHash(const void* data, size_t size, unsigned int n)
ostatic 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.
o 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.

o EST_THash(const EST_THash<K, V> &from)
Create a copy

o ~EST_THash(void)
Destroy the table

ovoid clear(void)
Empty the table

ounsigned int num_entries(void) const
Return the total number of entries in the table

oint present(const K &key) const
Does the key have an entry?

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

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

ovoid copy(const EST_THash<K, V> &from)
Copy all entries

ovoid map(void (*func)(K&, V&))
Apply <parameter>func</parameter> to each entry in the table

oint add_item(const K &key, const V &value, int no_search = 0)
Add an entry to the table

oint remove_item(const K &rkey, int quiet = 0)
Remove an entry from the table

oEST_THash<K,V> & operator = (const EST_THash<K, V> &from)
Assignment is a copy operation

ovoid dump(ostream &stream, int all=0)
Print the table to <parameter>stream</parameter> in a human readable format

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

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

ovoid skip_blank(IPointer &ip) const
Shift to point at something

ovoid point_to_first(IPointer &ip) const
Go to start of the table

ovoid move_pointer_forwards(IPointer &ip) const
Move pointer forwards, at the end of the bucket, move down

obool points_to_something(const IPointer &ip) const
We are at the end if the pointer ever becomes NULL

oEST_Hash_Pair<K, V> & points_at(const IPointer &ip)
Return the contents of this entry

otypedef EST_Hash_Pair<K, V> Entry
An entry returned by the iterator is a key value pair

otypedef EST_TStructIterator< EST_THash<K, V>, IPointer, EST_Hash_Pair<K, V> > Entries
Give the iterator a sensible name

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

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

ovoid skip_blank(IPointer_k &ip) const
Shift to point at something

ovoid point_to_first(IPointer_k &ip) const
Go to start of the table

ovoid move_pointer_forwards(IPointer_k &ip) const
Move pointer forwards, at the end of the bucket, move down

obool points_to_something(const IPointer_k &ip) const
We are at the end if the pointer ever becomes NULL

oK& points_at(const IPointer_k &ip)
Return the key of this entry

otypedef K KeyEntry
An entry returned by this iterator is just a key

otypedef 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