Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  
Public Member Functions | Private Member Functions | Private Attributes

SgHashTable< DATA > Class Template Reference

HashTable implements an array of DATA. More...

#include <SgHashTable.h>

List of all members.

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

Detailed Description

template<class DATA>
class SgHashTable< DATA >

HashTable implements an array of DATA.

Definition at line 37 of file SgHashTable.h.


Constructor & Destructor Documentation

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

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

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

template<class DATA >
bool SgHashTable< DATA >::Lookup ( const SgHashCode code,
DATA *  data 
) const
template<class DATA >
int SgHashTable< DATA >::MaxHash (  )  const

Size of hash table.

Definition at line 156 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 66 of file SgHashTable.h.

References SgHashTable< DATA >::m_nuCollisions.

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

number of successful lookups

Definition at line 84 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 78 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 72 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 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().


Member Data Documentation

template<class DATA >
SgHashEntry<DATA>* SgHashTable< DATA >::m_entry [private]
template<class DATA >
int SgHashTable< DATA >::m_maxHash [private]
template<class DATA >
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().

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

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

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


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


Sun Mar 13 2011 Doxygen 1.7.1