User Documentation
Centre for Vision, Speech & Signal Processing
DEVELOP IN NAMESPACE AMMA TREE ROOT AMMA SEARCH AMMA HOME
 

  PUBLIC
HashC::HashC(UIndex)
HashC::HashC(const HashC &)
HashC::HashC(istream &)
HashC::Copy(void) const
HashC::Lookup(const K &) const
HashC::Lookup(const K &)
HashC::Lookup(const K &,T &)
HashC::Update(const K &,const T &)
HashC::Update(const K &)
HashC::operator[](const K &)
HashC::operator[](const K &) const
HashC::Insert(const K &,const T &)
HashC::Access(const K &,const T &)
HashC::Del(const K &)
HashC::Get(const K &)
HashC::IsElm(const K &) const
HashC::Empty(void)
HashC::Size(void) const
HashC::IsEmpty(void) const
HashC::Bins(void) const
HashC::Resize(USize)
HashC::operator=(const HashC &)
HashC::IsSameTable(const HashC &) const
HashC::GetTable_Internal(void) const
HashC<class K,class T>
 
General hash table.
 
include "amma/Hash.hh"
User Level:Default
Library:Hash1d
Example:WordFreq.cc
Section:Containers.Hash Tables
In Scope:std

Comments:
It is recomended to use HashARC, unless you know how many items will be put in the table before its created.

Type K is the hash key, it mush define a function

unsigned int K::Hash(); which returns a number fairly unique to the key. or a global function of the form UIntT StdHash(const K &x) which returns the key.

bool K::operator== (const K &Oth); to test equality.

!!!!! Update() Require's a default constructor & a working assigment operator !!!!! Few things to bare in mind when writing StdHash() functions.

1) Try and use all the bits in the values being hashed.

2) Use quick operations that tend to preserve the number of bits in the value. ie '+' '^' '-'

3) Try and generate a hash value which uses as many bits as possible, but no more than the thing your hashing. i.e. ByteRGBValueC only uses 21 bits, and so does the default hash value.

4) For best results try and generate a function which distributes key values evenly over the range of hash values.

Parent Classes: Derived Classes: Typedefs:
typedef T ElementT;
Allow function templates to find type of array.

typedef K KeyT;
Allow function templates to find type of index.

typedef HashIterC<K,T> IteratorT;
Type of iterator.

typedef HashElemT<K,T> HashElem;

typedef SLListC<HashElemT<K,T>> HashElemLst;

typedef SLConstIterC<HashElemT<K,T>> HashElemConstIter;

typedef SLIterC<HashElemT<K,T>> HashElemIter;
Used in Del. These typedef's control the types of lists used in this class and it's iterator.

Variables:
Methods:
HashC(UIndex nBins = 23)
Create table with nBins.
Bin size must be at least 1.

HashC(const HashC<K,T> & Oth)
Copy access structure.

HashC(istream & in)
Recreate from stream.

HashC<K,T> Copy() const
Make a copy of the table.

const T * Lookup(const K & Key) const
Find data matching key.
Ptr == NULL, if matching key not found.

T * Lookup(const K & Key)
Find data matching key.
Ptr == NULL, if matching key not found.

BooleanT Lookup(const K & Key,T & data)
Lookup data for key.
Returns true if data is found, copy is place in 'data'.

BooleanT Update(const K & Key,const T & Data)
Update member of HashTable, will create new one if it doesn't
exist. Require's a default constructor & a working assigment operator !! Returns: True=Member existed already. False=New one was added.

T & Update(const K & Key)
Get value, add default if its not there. Return refrence anyway.

T & operator[](const K & Key)
Associative array style interface.

const T & operator[](const K & Key) const
Associative array style of access.

BooleanT Insert(const K & Key,const T & Data)
Default insertion operation, same as Update(K,T);

T & Access(const K & key,const T & def = T())
Access key, if it does exists create a new bin with value 'def'
Retuns a refrence to the new entry.

BooleanT Del(const K & Key)
Delete member from table.

T Get(const K & Key)
Get data element from table, and remove it.

BooleanT IsElm(const K & Key) const
Is key used in the table ?

void Empty(void)
Remove all items from table.

UIntT Size(void) const
Count number of elements in table.

BooleanT IsEmpty(void) const
Is the table empty ?

UIndex Bins(void) const
Number of bins in the HashTable.

void Resize(USize NewSize)
Resize HashCable.
WARNING: this empties the old table & creates a new one, so it will leave other handles pointing to an empty hash table.

const HashC<K,T> & operator=(const HashC<K,T> & Oth)
Assign from another hash table.

BooleanT IsSameTable(const HashC<K,T> & oth) const

SArray1dC<HashElemLst> & GetTable_Internal() const
Don't use this function, it's a bug work around, and I'll remove it as soon as gcc is fixed.


Programmer:Charles Galambos, Documentation by CxxDoc: Tue Mar 20 10:48:08 2001