HashTable implements an array of DATA. More...
#include <SgHashTable.h>
Public Member Functions | |
SgHashTable (int maxHash) | |
Create a hash table with 'maxHash' entries. | |
~SgHashTable () | |
void | Age () |
Leaves the positions in the hash table, but set all depths to zero, so that only the best move is valid, not the value. | |
void | Clear () |
Clear the hash table by marking all entries as invalid. | |
bool | Lookup (const SgHashCode &code, DATA *data) const |
Return true and the data stored under that code, or false if none stored. | |
int | MaxHash () const |
Size of hash table. | |
bool | Store (const SgHashCode &code, const DATA &data) |
Try to store 'data' under the hash code 'code'. | |
int | NuCollisions () const |
number of collisions on store | |
int | NuStores () const |
total number of stores attempted | |
int | NuLookups () const |
total number of lookups attempted | |
int | NuFound () const |
number of successful lookups | |
Private Member Functions | |
SgHashTable (const SgHashTable &) | |
not implemented | |
SgHashTable & | operator= (const SgHashTable &) |
not implemented | |
Private Attributes | |
SgHashEntry< DATA > * | m_entry |
complete hash code for each entry | |
int | m_maxHash |
size of hash table | |
int | m_nuCollisions |
number of collisions on store | |
int | m_nuStores |
total number of stores attempted | |
int | m_nuLookups |
total number of lookups attempted | |
int | m_nuFound |
number of successful lookups |
HashTable implements an array of DATA.
Definition at line 37 of file SgHashTable.h.
SgHashTable< DATA >::SgHashTable | ( | int | maxHash | ) | [explicit] |
Create a hash table with 'maxHash' entries.
Definition at line 119 of file SgHashTable.h.
References SgHashTable< DATA >::Clear(), SgHashTable< DATA >::m_entry, and SgHashTable< DATA >::m_maxHash.
SgHashTable< DATA >::~SgHashTable | ( | ) |
Definition at line 132 of file SgHashTable.h.
References SgHashTable< DATA >::m_entry.
SgHashTable< DATA >::SgHashTable | ( | const SgHashTable< DATA > & | ) | [private] |
not implemented
void SgHashTable< DATA >::Age | ( | ) |
Leaves the positions in the hash table, but set all depths to zero, so that only the best move is valid, not the value.
The hash entries will easily be replaced by fresh information.
Definition at line 138 of file SgHashTable.h.
References SgHashTable< DATA >::m_entry, and SgHashTable< DATA >::m_maxHash.
void SgHashTable< DATA >::Clear | ( | ) |
Clear the hash table by marking all entries as invalid.
Definition at line 147 of file SgHashTable.h.
References SgHashTable< DATA >::m_entry, and SgHashTable< DATA >::m_maxHash.
Referenced by SgSearch::DepthFirstSearch(), SgSearch::IteratedSearch(), and SgHashTable< DATA >::SgHashTable().
bool SgHashTable< DATA >::Lookup | ( | const SgHashCode & | code, | |
DATA * | data | |||
) | const |
Return true and the data stored under that code, or false if none stored.
Definition at line 179 of file SgHashTable.h.
References SgHash< N >::Hash(), SgHashEntry< DATA >::m_data, SgHashTable< DATA >::m_entry, SgHashEntry< DATA >::m_hash, SgHashTable< DATA >::m_maxHash, SgHashTable< DATA >::m_nuFound, and SgHashTable< DATA >::m_nuLookups.
Referenced by SgSearch::LookupHash().
int SgHashTable< DATA >::MaxHash | ( | ) | const |
Size of hash table.
Definition at line 156 of file SgHashTable.h.
References SgHashTable< DATA >::m_maxHash.
int SgHashTable< DATA >::NuCollisions | ( | ) | const |
number of collisions on store
Definition at line 66 of file SgHashTable.h.
References SgHashTable< DATA >::m_nuCollisions.
int SgHashTable< DATA >::NuFound | ( | ) | const |
number of successful lookups
Definition at line 84 of file SgHashTable.h.
References SgHashTable< DATA >::m_nuFound.
int SgHashTable< DATA >::NuLookups | ( | ) | const |
total number of lookups attempted
Definition at line 78 of file SgHashTable.h.
References SgHashTable< DATA >::m_nuLookups.
int SgHashTable< DATA >::NuStores | ( | ) | const |
total number of stores attempted
Definition at line 72 of file SgHashTable.h.
References SgHashTable< DATA >::m_nuStores.
SgHashTable& SgHashTable< DATA >::operator= | ( | const SgHashTable< DATA > & | ) | [private] |
not implemented
bool SgHashTable< DATA >::Store | ( | const SgHashCode & | code, | |
const DATA & | data | |||
) |
Try to store 'data' under the hash code 'code'.
Return whether the data was stored. The only reason for not storing it would be some 'better' data already hashing to the same hash code.
Definition at line 162 of file SgHashTable.h.
References SgHash< N >::Hash(), SgHashEntry< DATA >::m_data, SgHashTable< DATA >::m_entry, SgHashEntry< DATA >::m_hash, SgHashTable< DATA >::m_maxHash, SgHashTable< DATA >::m_nuCollisions, and SgHashTable< DATA >::m_nuStores.
Referenced by SgSearch::AddSequenceToHash(), and SgSearch::StoreHash().
SgHashEntry<DATA>* SgHashTable< DATA >::m_entry [private] |
complete hash code for each entry
Definition at line 91 of file SgHashTable.h.
Referenced by SgHashTable< DATA >::Age(), SgHashTable< DATA >::Clear(), SgHashTable< DATA >::Lookup(), SgHashTable< DATA >::SgHashTable(), SgHashTable< DATA >::Store(), and SgHashTable< DATA >::~SgHashTable().
int SgHashTable< DATA >::m_maxHash [private] |
size of hash table
Definition at line 94 of file SgHashTable.h.
Referenced by SgHashTable< DATA >::Age(), SgHashTable< DATA >::Clear(), SgHashTable< DATA >::Lookup(), SgHashTable< DATA >::MaxHash(), SgHashTable< DATA >::SgHashTable(), and SgHashTable< DATA >::Store().
int SgHashTable< DATA >::m_nuCollisions [mutable, private] |
number of collisions on store
Definition at line 100 of file SgHashTable.h.
Referenced by SgHashTable< DATA >::NuCollisions(), and SgHashTable< DATA >::Store().
int SgHashTable< DATA >::m_nuFound [mutable, private] |
number of successful lookups
Definition at line 109 of file SgHashTable.h.
Referenced by SgHashTable< DATA >::Lookup(), and SgHashTable< DATA >::NuFound().
int SgHashTable< DATA >::m_nuLookups [mutable, private] |
total number of lookups attempted
Definition at line 106 of file SgHashTable.h.
Referenced by SgHashTable< DATA >::Lookup(), and SgHashTable< DATA >::NuLookups().
int SgHashTable< DATA >::m_nuStores [mutable, private] |
total number of stores attempted
Definition at line 103 of file SgHashTable.h.
Referenced by SgHashTable< DATA >::NuStores(), and SgHashTable< DATA >::Store().