Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SgHashTable< DATA > Class Template Reference

#include <SgHashTable.h>

List of all members.


Detailed Description

template<class DATA>
class SgHashTable< DATA >

HashTable implements an array of DATA.

Definition at line 38 of file 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
SgHashTableoperator= (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


Constructor & Destructor Documentation

template<class DATA>
SgHashTable< DATA >::SgHashTable ( int  maxHash  )  [explicit]

Create a hash table with 'maxHash' entries.

Definition at line 123 of file SgHashTable.h.

References SgHashTable< DATA >::Clear(), SgHashTable< DATA >::m_entry, and SgHashTable< DATA >::m_maxHash.

template<class DATA>
SgHashTable< DATA >::~SgHashTable (  ) 

Definition at line 136 of file SgHashTable.h.

References SgHashTable< DATA >::m_entry.

template<class DATA>
SgHashTable< DATA >::SgHashTable ( const SgHashTable< DATA > &   )  [private]

not implemented


Member Function Documentation

template<class DATA>
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 142 of file SgHashTable.h.

References SgHashTable< DATA >::m_entry, and SgHashTable< DATA >::m_maxHash.

template<class DATA>
void SgHashTable< DATA >::Clear (  ) 

Clear the hash table by marking all entries as invalid.

Definition at line 151 of file SgHashTable.h.

References SgHashTable< DATA >::m_entry, and SgHashTable< DATA >::m_maxHash.

Referenced by SgSearch::DepthFirstSearch(), SgSearch::IteratedSearch(), and SgHashTable< DATA >::SgHashTable().

template<class DATA>
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 183 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().

template<class DATA>
int SgHashTable< DATA >::MaxHash (  )  const

Size of hash table.

Definition at line 160 of file SgHashTable.h.

References SgHashTable< DATA >::m_maxHash.

template<class DATA>
int SgHashTable< DATA >::NuCollisions (  )  const

number of collisions on store

Definition at line 70 of file SgHashTable.h.

References SgHashTable< DATA >::m_nuCollisions.

template<class DATA>
int SgHashTable< DATA >::NuFound (  )  const

number of successful lookups

Definition at line 88 of file SgHashTable.h.

References SgHashTable< DATA >::m_nuFound.

template<class DATA>
int SgHashTable< DATA >::NuLookups (  )  const

total number of lookups attempted

Definition at line 82 of file SgHashTable.h.

References SgHashTable< DATA >::m_nuLookups.

template<class DATA>
int SgHashTable< DATA >::NuStores (  )  const

total number of stores attempted

Definition at line 76 of file SgHashTable.h.

References SgHashTable< DATA >::m_nuStores.

template<class DATA>
SgHashTable& SgHashTable< DATA >::operator= ( const SgHashTable< DATA > &   )  [private]

not implemented

template<class DATA>
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 166 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().


Member Data Documentation

template<class DATA>
SgHashEntry<DATA>* SgHashTable< DATA >::m_entry [private]

complete hash code for each entry

Definition at line 95 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().

template<class DATA>
int SgHashTable< DATA >::m_maxHash [private]

size of hash table

Definition at line 98 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().

template<class DATA>
int SgHashTable< DATA >::m_nuCollisions [mutable, private]

number of collisions on store

Definition at line 104 of file SgHashTable.h.

Referenced by SgHashTable< DATA >::NuCollisions(), and SgHashTable< DATA >::Store().

template<class DATA>
int SgHashTable< DATA >::m_nuFound [mutable, private]

number of successful lookups

Definition at line 113 of file SgHashTable.h.

Referenced by SgHashTable< DATA >::Lookup(), and SgHashTable< DATA >::NuFound().

template<class DATA>
int SgHashTable< DATA >::m_nuLookups [mutable, private]

total number of lookups attempted

Definition at line 110 of file SgHashTable.h.

Referenced by SgHashTable< DATA >::Lookup(), and SgHashTable< DATA >::NuLookups().

template<class DATA>
int SgHashTable< DATA >::m_nuStores [mutable, private]

total number of stores attempted

Definition at line 107 of file SgHashTable.h.

Referenced by SgHashTable< DATA >::NuStores(), and SgHashTable< DATA >::Store().


The documentation for this class was generated from the following file:


17 Jun 2010 Doxygen 1.4.7