Files Classes Functions Hierarchy
#include <hashtable.h>
Public Types | |
| typedef bucketlink< T > * | blink |
Public Member Functions | |
| hashtable (uintc bucketsize_, HFN fn_) | |
| Pre allocate memory requirements before use, do not put this class in a loop. | |
| ~hashtable () | |
| Destructor releases the memory used. | |
| hashtable () | |
| Construct in a bad state. | |
| void | construct (uintc bucketsize_) |
| Resize the container - invalidates previous memory. | |
| void | insert (bucketlink< T > *x) |
| Put a value into the hash table. | |
| bucketlink< T > * | insertInverse (T const &key) const |
| Get the link to the data if it exists, else 0 returned. | |
| boolc | remove (T const &key) |
| Removes the bucket link which compared == with d. | |
| boolc | contains (T const &key) const |
| Is the element in the hash table? | |
Public Attributes | |
| uint | bucketsize |
| Size of vb. | |
| HFN | fn |
| Hash function. | |
| bucketlink< T > ** | vb |
| Public if the client wishes to iterate linearly through the hash data structure, another property of hash tables. | |
Interface for template HFN parameter
class HFN
{
public:
uintc operator()(uintc key) const;
};
string dict[] = { "abc", "nogo", "python" };
uintc n(3);
vector< bucketlink<string> > v(n);
for (uint i=0; i<n; ++i)
v[i] = bucketlink<string>(&dict[i]);
uintc hashtablesize(70);
stringhash h(32,8);
hashtable<string,stringhash&> H(hashtablesize,h);
for (uint i=0; i<n; ++i)
H.insert( & v[i] );
Definition at line 40 of file hashtable.h.
| typedef bucketlink<T>* hashtable< T, HFN >::blink |
Definition at line 54 of file hashtable.h.
Pre allocate memory requirements before use, do not put this class in a loop.
Destructor releases the memory used.
| boolc hashtable< T, HFN >::contains | ( | T const & | key | ) | const [inline] |
Is the element in the hash table?
Definition at line 85 of file hashtable.h.
Referenced by cfcontainerhash::add(), hashtabletest::test01(), and hashtabletest::test07().
00086 { return insertInverse(key)!=0; }
| void hashtable< T, HFN >::insert | ( | bucketlink< T > * | x | ) |
Put a value into the hash table.
The client manages the memory of x.
Referenced by cfcontainerhash::add(), hashtabletest::test01(), hashtabletest::test02unit(), hashtabletest::test05(), hashtabletest::test06(), and hashtabletest::test07().
| bucketlink<T>* hashtable< T, HFN >::insertInverse | ( | T const & | key | ) | const |
Get the link to the data if it exists, else 0 returned.
The client can potentially modify the data (and corrupt this entry), so only modify non-key attributes.
Referenced by hashtable< sp, sph & >::contains(), cfcontainerhash::operator[](), hashtabletest::test01(), and hashtabletest::test02unit().
Removes the bucket link which compared == with d.
Referenced by cfcontainerhash::remove(), and hashtabletest::test07().
| uint hashtable< T, HFN >::bucketsize |
Size of vb.
Definition at line 45 of file hashtable.h.
Referenced by hashtable< T, HFN >::construct(), hashtable< sp, sph & >::hashtable(), hashtable< T, HFN >::insert(), and hashtabletest::test05().
Hash function.
Definition at line 47 of file hashtable.h.
Referenced by hashtable< T, HFN >::insert().
| bucketlink<T>* * hashtable< T, HFN >::vb |
Public if the client wishes to iterate linearly through the hash data structure, another property of hash tables.
Definition at line 52 of file hashtable.h.
Referenced by hashtable< T, HFN >::construct(), hashtable< T, HFN >::insert(), hashtabletest::test05(), and hashtable< T, HFN >::~hashtable().
1.5.8