User Documentation |
RAVL, Recognition And Vision Library |
Comments:
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 !!!!!
A 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 HashElemC<K,T> HashElem;
-
- typedef IntrDListC<HashElemC<K,T>> HashElemLst;
-
- typedef IntrDLIterC<HashElemC<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(UIntT nBins = 23)
-
Create table with nBins.
Bin size must be at least 1.
- HashC(const HashC<K,T> & oth)
-
Copy access structure.
- HashC(Tuple2C<K,T> * data)
-
Initalise from simple array.
NB. Array must be terminated by a duplicate of
the first key. (i.e. == must return true between them)
- HashC(istream & in)
-
Recreate from stream.
- HashC(BinIStreamC & 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.
Do not use, Try Lookup(key,data);
Ptr == NULL, if matching key not found.
- T * Lookup(const K & Key)
-
Find data matching key.
Do not use, Try Lookup(key,data);
Ptr == NULL, if matching key not found.
- bool Lookup(const K & Key,T & data) const
-
Lookup data for key.
Returns true if entry is found, and is assigned to 'data'.
- bool Update(const K & Key,const T & Data)
-
Update member of hash table, 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 reference anyway.
- T & operator [](const K & Key)
-
Associative array style interface.
- const T & operator [](const K & Key) const
-
Associative array style of access.
- bool 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 not exist create a new bin with value 'def'
Retuns a reference to the entry.
- T & AccessCopy(const K & key,const T & def = T ())
-
Access key, if it does not exist create a new bin with a copy of value 'def'
Retuns a reference to the entry.
- bool Del(const K & Key,bool allowResize = true)
-
Delete member from table.
- T Get(const K & Key,bool allowResize = true)
-
Get data element from table, and remove it.
- bool IsElm(const K & Key) const
-
Is key used in the table ?
- void Empty(void)
-
Remove all items from table.
- UIntT Bins(void) const
-
Number of bins in the HashTable.
- void Resize(SizeT NewSize)
-
Resize hash table.
- const HashC<K,T> & operator =(const HashC<K,T> & oth)
-
Assign from another hash table.
- bool operator ==(const HashC<K,T> & oth) const
-
Are two hash tables identical ?
- bool operator !=(const HashC<K,T> & oth) const
-
Are two hash tables different ?
- UIntT Hash() const
-
Compute a hash value for the hash table.
- void Move(HashC<K,T> & oth)
-
Move contents of another table into this one.
leave other empty. The previous contents of this table are removed.
- void AddFrom(HashC<K,T> & oth,bool replace = true)
-
Add contents of another table into this one.
leave other empty. if replace is false the contents of the
old table are not replace by the new entries.
- void Add(const HashC<K,T> & oth,bool replace = true)
-
Add contents of another table into this one.
if replace is false the contents of the
old table are not replace by the new entries.
- bool IsEmpty() const
-
Is the table empty ?
- UIntT Size() const
-
Count number of elements in table.
- SizeT NextPrime(SizeT v)
-
Get the next prime not smaller than v.
Maintainer:Charles Galambos, Created: 1/9/1996, Documentation by CxxDoc: Tue Aug 13 09:59:02 2002
|