#include <Hash.h>
Inheritance diagram for PLearn::Hash< KeyType, DataType >:


Public Member Functions | |
| bool | add (const KeyType &, const DataType &) |
| returns false if table is full | |
| void | addAndResize (const KeyType &, const DataType &) |
| add() and resize() if resizeTime() | |
| bool | element (const KeyType &) |
| bool | del (const KeyType &) |
| unsigned int | hashAddress (const KeyType &) |
| returns Hash_UNUSED_TAG (-1) if not in table | |
| DataType * | operator[] (unsigned int addr) const |
| !< | |
| KeyType * | operator() (unsigned int addr) const |
| !< | |
| HashKeyDataPair< KeyType, DataType > ** | getTable () const |
| unsigned int | size () const |
| !< | |
| unsigned int | cardinal () const |
| !< | |
| void | flush () |
| cleans the table without resizing it | |
| void | initializeTable (unsigned int size) |
| !< | |
| bool | full () const |
| is the table full? | |
| bool | resizeTime () const |
| is it time to resize the table? | |
| void | resize (int newsize=-1) |
| resizes the table to maintain a good sparseness (default=-1 quadruples the table size) | |
| void | cleanup () |
| cleanup the table to maintain efficiency | |
| unsigned int | probes () const |
| returns the number of probe generate by last query | |
| void | diagnostics (unsigned int &clusters, unsigned int &maxCluster) const |
| Hash (unsigned int size=10000, bool static_allocation=false) | |
| !< | |
| ~Hash () | |
Public Attributes | |
| bool | isStatic |
| static or dynamic memory allocation | |
Private Member Functions | |
| unsigned int | hashKey (const KeyType &) const |
| computes the primary hash function on the string (length=0 says to look for in bytes to determine length) | |
| void | computePace () |
| computes the magic number used by the secondary hash function | |
| unsigned int | pgcd (unsigned int, unsigned int) const |
| unsigned int | find (const KeyType &) |
| returns either an empty slot or the slot with the key in it | |
| unsigned int | findGap (const KeyType &) |
| returns the first empty slot it finds | |
| Hash (const Hash &obj) | |
| The copy constructor is not yet defined... | |
| void | operator= (const Hash &obj) |
| not permitted... | |
Private Attributes | |
| HashKeyDataPair< KeyType, DataType > ** | table |
| a pointer to a table of <key,data> | |
| unsigned int | tableSize |
| total number of slots | |
| unsigned int | elements |
| number of used slots | |
| unsigned int | pace |
| used by the secondary hash function | |
| unsigned int | jumps |
| number of probes in last operation | |
| bool | static_tables_initialized |
| true when the tables are initialized | |
| KeyType * | key_table |
| DataType * | data_table |
| HashKeyDataPair< KeyType, DataType > * | hash_table |
| unsigned int | next_free_slot |
| the next free slot in the 3 tables | |
|
||||||||||||||||
|
!< Creates the table with size entries allocates a table of 0s Definition at line 550 of file Hash.h. References PLearn::Hash< KeyType, DataType >::computePace(), and PLearn::Hash< KeyType, DataType >::table. |
|
|||||||||
|
||||||||||
|
The copy constructor is not yet defined...
|
|
||||||||||||||||
|
returns false if table is full Return False only if the table is full. Use resizeTime() to determine if the table should be resized if already element delete it < no slot found (bummer!) < no slot found (bummer!) Definition at line 286 of file Hash.h. References PLearn::Hash< KeyType, DataType >::data_table, PLearn::Hash< KeyType, DataType >::elements, PLearn::Hash< KeyType, DataType >::findGap(), PLearn::Hash_DELETED_SLOT, PLearn::Hash< KeyType, DataType >::hash_table, PLearn::Hash< KeyType, DataType >::isStatic, PLearn::Hash< KeyType, DataType >::key_table, PLearn::Hash< KeyType, DataType >::next_free_slot, PLERROR, PLearn::Hash< KeyType, DataType >::static_tables_initialized, PLearn::Hash< KeyType, DataType >::table, and PLearn::Hash< KeyType, DataType >::tableSize. Referenced by PLearn::Hash< KeyType, DataType >::cleanup(), PLearn::SimpleDB< KeyType, QueryResult >::indexColumn(), and PLearn::Hash< KeyType, DataType >::resize(). |
|
||||||||||||||||
|
add() and resize() if resizeTime() call add() and resize() if resizeTime() Definition at line 325 of file Hash.h. References PLearn::add(), resize(), and PLearn::Hash< KeyType, DataType >::resizeTime(). |
|
|||||||||
|
!< returns the number of used slots. Definition at line 394 of file Hash.h. References PLearn::Hash< KeyType, DataType >::elements. |
|
|||||||||
|
cleanup the table to maintain efficiency Cleans the table after some "deletes" < dont deallocate t's table Definition at line 458 of file Hash.h. References PLearn::Hash< KeyType, DataType >::add(), PLearn::Hash< KeyType, DataType >::elements, PLearn::Hash< KeyType, DataType >::flush(), PLearn::Hash_DELETED_SLOT, PLearn::Hash< KeyType, DataType >::pace, PLearn::Hash< KeyType, DataType >::table, and PLearn::Hash< KeyType, DataType >::tableSize. |
|
|||||||||
|
computes the magic number used by the secondary hash function The pace is the secondary hash function. rather than doing a straight forward linear probing, we do a pseudorandomized probing Definition at line 222 of file Hash.h. References PLearn::Hash< KeyType, DataType >::pace, PLearn::Hash< KeyType, DataType >::pgcd(), and PLearn::Hash< KeyType, DataType >::tableSize. Referenced by PLearn::Hash< KeyType, DataType >::Hash(). |
|
||||||||||
|
deletes the entry, but leaves a marker so that probes continue to work properly Definition at line 337 of file Hash.h. References PLearn::Hash< KeyType, DataType >::elements, PLearn::find(), PLearn::Hash_DELETED_SLOT, PLearn::Hash< KeyType, DataType >::isStatic, and PLearn::Hash< KeyType, DataType >::table. |
|
||||||||||||||||
|
Definition at line 607 of file Hash.h. References __max, PLearn::Hash< KeyType, DataType >::table, and PLearn::Hash< KeyType, DataType >::tableSize. Referenced by PLearn::SimpleDB< KeyType, QueryResult >::indexColumn(). |
|
||||||||||
|
returns true if the string is in the table, false otherwise Definition at line 358 of file Hash.h. References PLearn::find(), PLearn::Hash_DELETED_SLOT, and PLearn::Hash< KeyType, DataType >::table. |
|
||||||||||
|
returns either an empty slot or the slot with the key in it find will stop either on an empty slot or on a slot that contains the searched string. while ( (table[h]>Hash_DELETED_SLOT) && //!< FIX ABOVE PROBLEM PROBLEME GRAVE ICI: si key->h mais h est occupe, donc key-> jump to h' ensuite si table[h] a ete delete un find(key) donnera h (qui contient "Hash_DELETED_SLOT") plutot que h' Definition at line 236 of file Hash.h. References PLearn::Hash_DELETED_SLOT, PLearn::Hash< KeyType, DataType >::hashKey(), PLearn::Hash< KeyType, DataType >::jumps, PLearn::Hash< KeyType, DataType >::pace, PLearn::Hash< KeyType, DataType >::table, and PLearn::Hash< KeyType, DataType >::tableSize. |
|
||||||||||
|
returns the first empty slot it finds find will stop either on an empty slot or on a slot that contains the searched string. Definition at line 264 of file Hash.h. References PLearn::Hash_DELETED_SLOT, PLearn::Hash< KeyType, DataType >::hashKey(), PLearn::Hash< KeyType, DataType >::jumps, PLearn::Hash< KeyType, DataType >::pace, PLearn::Hash< KeyType, DataType >::table, and PLearn::Hash< KeyType, DataType >::tableSize. Referenced by PLearn::Hash< KeyType, DataType >::add(). |
|
|||||||||
|
cleans the table without resizing it Erases all strings, but does not destroy the table itself Definition at line 509 of file Hash.h. References PLearn::Hash< KeyType, DataType >::elements, PLearn::Hash_DELETED_SLOT, PLearn::Hash< KeyType, DataType >::isStatic, PLearn::Hash< KeyType, DataType >::table, and PLearn::Hash< KeyType, DataType >::tableSize. Referenced by PLearn::Hash< KeyType, DataType >::cleanup(), PLearn::SimpleDB< KeyType, QueryResult >::indexColumn(), PLearn::Hash< KeyType, DataType >::resize(), and PLearn::Hash< KeyType, DataType >::~Hash(). |
|
|||||||||
|
is the table full? Tells you if you should resize the table now. Definition at line 417 of file Hash.h. References PLearn::Hash< KeyType, DataType >::elements, and PLearn::Hash< KeyType, DataType >::tableSize. |
|
|||||||||
|
Definition at line 123 of file Hash.h. References PLearn::Hash< KeyType, DataType >::table. |
|
||||||||||
|
returns Hash_UNUSED_TAG (-1) if not in table Gives the address in the table of the string (possibly Hash_UNUSED_TAG if there is no such string in the table) Definition at line 371 of file Hash.h. References PLearn::find(), PLearn::Hash_DELETED_SLOT, PLearn::Hash_UNUSED_TAG, and PLearn::Hash< KeyType, DataType >::table. Referenced by PLearn::SimpleDB< KeyType, QueryResult >::findEqualIndexed(), and PLearn::SimpleDB< KeyType, QueryResult >::indexColumn(). |
|
||||||||||
|
computes the primary hash function on the string (length=0 says to look for in bytes to determine length) Computes the remainder (mod AMagicNumber) of the key Definition at line 186 of file Hash.h. References PLearn::Hash_NOMBRES_MAGIQUES, PLearn::Hash< KeyType, DataType >::hashKey(), and PLearn::Hash< KeyType, DataType >::tableSize. Referenced by PLearn::Hash< KeyType, DataType >::find(), PLearn::Hash< KeyType, DataType >::findGap(), and PLearn::Hash< KeyType, DataType >::hashKey(). |
|
||||||||||
|
!< Creates the static table with size entries Definition at line 529 of file Hash.h. References PLearn::Hash< KeyType, DataType >::data_table, PLearn::Hash< KeyType, DataType >::hash_table, PLearn::Hash< KeyType, DataType >::isStatic, PLearn::Hash< KeyType, DataType >::key_table, PLERROR, PLWARNING, and PLearn::Hash< KeyType, DataType >::static_tables_initialized. |
|
||||||||||
|
!< Arguments to () is hashAddress Definition at line 494 of file Hash.h. References PLearn::Hash_DELETED_SLOT, and PLearn::Hash< KeyType, DataType >::table. |
|
||||||||||
|
not permitted...
Definition at line 148 of file Hash.h. References PLearn::Hash< KeyType, DataType >::operator=(). Referenced by PLearn::Hash< KeyType, DataType >::operator=(). |
|
||||||||||
|
!< Arguments to [] is hashAddress Definition at line 482 of file Hash.h. References PLearn::Hash_DELETED_SLOT, and PLearn::Hash< KeyType, DataType >::table. |
|
||||||||||||||||
|
Definition at line 204 of file Hash.h. Referenced by PLearn::Hash< KeyType, DataType >::computePace(). |
|
|||||||||
|
returns the number of probe generate by last query
Definition at line 595 of file Hash.h. References PLearn::Hash< KeyType, DataType >::jumps. |
|
||||||||||
|
resizes the table to maintain a good sparseness (default=-1 quadruples the table size) Resizes the table by producing an enlarged copy (not in situ rehashing) < dont deallocate t's table Definition at line 429 of file Hash.h. References PLearn::Hash< KeyType, DataType >::add(), PLearn::Hash< KeyType, DataType >::elements, PLearn::endl(), PLearn::Hash< KeyType, DataType >::flush(), PLearn::Hash_DELETED_SLOT, PLearn::Hash< KeyType, DataType >::pace, PLearn::Hash< KeyType, DataType >::table, and PLearn::Hash< KeyType, DataType >::tableSize. Referenced by PLearn::SimpleDB< KeyType, QueryResult >::indexColumn(). |
|
|||||||||
|
is it time to resize the table? Tells you if you should resize the table now. Definition at line 406 of file Hash.h. References PLearn::Hash< KeyType, DataType >::elements, and PLearn::Hash< KeyType, DataType >::tableSize. Referenced by PLearn::Hash< KeyType, DataType >::addAndResize(). |
|
|||||||||
|
!< returns the total number of slots Definition at line 385 of file Hash.h. References PLearn::Hash< KeyType, DataType >::tableSize. |
|
|||||
|
Definition at line 107 of file Hash.h. Referenced by PLearn::Hash< KeyType, DataType >::add(), PLearn::Hash< KeyType, DataType >::initializeTable(), and PLearn::Hash< KeyType, DataType >::~Hash(). |
|
|||||
|
|||||
|
Definition at line 108 of file Hash.h. Referenced by PLearn::Hash< KeyType, DataType >::add(), PLearn::Hash< KeyType, DataType >::initializeTable(), and PLearn::Hash< KeyType, DataType >::~Hash(). |
|
|||||
|
static or dynamic memory allocation
Definition at line 112 of file Hash.h. Referenced by PLearn::Hash< KeyType, DataType >::add(), PLearn::Hash< KeyType, DataType >::del(), PLearn::Hash< KeyType, DataType >::flush(), PLearn::Hash< KeyType, DataType >::initializeTable(), and PLearn::Hash< KeyType, DataType >::~Hash(). |
|
|||||
|
number of probes in last operation
Definition at line 95 of file Hash.h. Referenced by PLearn::Hash< KeyType, DataType >::find(), PLearn::Hash< KeyType, DataType >::findGap(), and PLearn::Hash< KeyType, DataType >::probes(). |
|
|||||
|
Definition at line 106 of file Hash.h. Referenced by PLearn::Hash< KeyType, DataType >::add(), PLearn::Hash< KeyType, DataType >::initializeTable(), and PLearn::Hash< KeyType, DataType >::~Hash(). |
|
|||||
|
the next free slot in the 3 tables
Definition at line 109 of file Hash.h. Referenced by PLearn::Hash< KeyType, DataType >::add(). |
|
|||||
|
used by the secondary hash function
Definition at line 94 of file Hash.h. Referenced by PLearn::Hash< KeyType, DataType >::cleanup(), PLearn::Hash< KeyType, DataType >::computePace(), PLearn::Hash< KeyType, DataType >::find(), PLearn::Hash< KeyType, DataType >::findGap(), and PLearn::Hash< KeyType, DataType >::resize(). |
|
|||||
|
true when the tables are initialized
Definition at line 105 of file Hash.h. Referenced by PLearn::Hash< KeyType, DataType >::add(), and PLearn::Hash< KeyType, DataType >::initializeTable(). |
|
|||||
|
|||||
1.3.7