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

SgHash< N > Class Template Reference

N-bit hash codes. More...

#include <SgHash.h>

List of all members.

Public Member Functions

 SgHash ()
 Costruct hash code initialized with zero.
 SgHash (unsigned int key)
 Construct hash code from integer index.
 ~SgHash ()
void Clear ()
 Reinitialize the hash code.
void Invalidate ()
 Set to random value.
bool operator< (const SgHash &code) const
bool operator== (const SgHash &code) const
bool operator!= (const SgHash &code) const
bool IsZero () const
void Xor (const SgHash &code)
 Combine this hash code with the given hash code.
unsigned int Hash (int max) const
 Use this hash code to hash into a table with 'max' elements.
unsigned int Code1 () const
 First integer (deprecated).
unsigned int Code2 () const
 Second integer (deprecated).
void RollLeft (int n)
 Roll bits n places to the left.
void RollRight (int n)
 Roll bits n places to the right.
std::string ToString () const
 Convert hash code to string.
void FromString (const std::string &str)
 Convert string to hash code.

Static Public Member Functions

static SgHash Random ()
 Return a random hash code.
static int Size ()

Private Member Functions

unsigned int Mix32 (int key) const
 Thomas Wang's 32 bit mix function.
unsigned int GetWord () const

Private Attributes

std::bitset< N > m_code

Detailed Description

template<int N>
class SgHash< N >

N-bit hash codes.

Definition at line 26 of file SgHash.h.


Constructor & Destructor Documentation

template<int N>
SgHash< N >::SgHash (  ) 

Costruct hash code initialized with zero.

Definition at line 30 of file SgHash.h.

template<int N>
SgHash< N >::SgHash ( unsigned int  key  ) 

Construct hash code from integer index.

Definition at line 99 of file SgHash.h.

References SgHash< N >::GetWord(), SgHash< N >::m_code, and SgHash< N >::Mix32().

template<int N>
SgHash< N >::~SgHash (  ) 

Definition at line 35 of file SgHash.h.


Member Function Documentation

template<int N>
void SgHash< N >::Clear (  ) 

Reinitialize the hash code.

Caution: after Clear() hash code matches code of empty board.

Definition at line 141 of file SgHash.h.

References SgHash< N >::m_code.

Referenced by SgStrategy::Clear(), and SgHash< N >::FromString().

template<int N>
unsigned int SgHash< N >::Code1 (  )  const

First integer (deprecated).

Deprecated:
Don't use this function; it exposes implementation details.

Definition at line 147 of file SgHash.h.

References SgHash< N >::GetWord().

template<int N>
unsigned int SgHash< N >::Code2 (  )  const

Second integer (deprecated).

Deprecated:
Don't use this function; it exposes implementation details.

Definition at line 153 of file SgHash.h.

References SgHash< N >::m_code.

template<int N>
void SgHash< N >::FromString ( const std::string &  str  ) 

Convert string to hash code.

Definition at line 159 of file SgHash.h.

References SgHash< N >::Clear(), and SgHash< N >::m_code.

Referenced by operator>>().

template<int N>
unsigned int SgHash< N >::GetWord (  )  const [private]

Definition at line 178 of file SgHash.h.

References SgHash< N >::m_code.

Referenced by SgHash< N >::Code1(), SgHash< N >::Hash(), and SgHash< N >::SgHash().

template<int N>
unsigned int SgHash< N >::Hash ( int  max  )  const

Use this hash code to hash into a table with 'max' elements.

Definition at line 185 of file SgHash.h.

References SgHash< N >::GetWord().

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

template<int N>
void SgHash< N >::Invalidate (  ) 

Set to random value.

Definition at line 191 of file SgHash.h.

References SgHash< N >::Random().

template<int N>
bool SgHash< N >::IsZero (  )  const

Definition at line 197 of file SgHash.h.

References SgHash< N >::m_code.

template<int N>
unsigned int SgHash< N >::Mix32 ( int  key  )  const [private]

Thomas Wang's 32 bit mix function.

Definition at line 203 of file SgHash.h.

Referenced by SgHash< N >::SgHash().

template<int N>
bool SgHash< N >::operator!= ( const SgHash< N > &  code  )  const

Definition at line 135 of file SgHash.h.

References SgHash< N >::m_code.

template<int N>
bool SgHash< N >::operator< ( const SgHash< N > &  code  )  const

Definition at line 112 of file SgHash.h.

References SgHash< N >::m_code.

template<int N>
bool SgHash< N >::operator== ( const SgHash< N > &  code  )  const

Definition at line 129 of file SgHash.h.

References SgHash< N >::m_code.

template<int N>
SgHash< N > SgHash< N >::Random (  )  [static]

Return a random hash code.

Returns:
A random hash code, which is not zero.

Definition at line 215 of file SgHash.h.

References SgRandom::Global(), SgRandom::Int(), and SgHash< N >::m_code.

Referenced by SgHash< N >::Invalidate().

template<int N>
void SgHash< N >::RollLeft ( int  n  ) 

Roll bits n places to the left.

Definition at line 229 of file SgHash.h.

References SgHash< N >::m_code.

template<int N>
void SgHash< N >::RollRight ( int  n  ) 

Roll bits n places to the right.

Definition at line 235 of file SgHash.h.

References SgHash< N >::m_code.

template<int N>
int SgHash< N >::Size (  )  [static]

Definition at line 241 of file SgHash.h.

template<int N>
std::string SgHash< N >::ToString (  )  const

Convert hash code to string.

Definition at line 247 of file SgHash.h.

References SgHash< N >::m_code.

template<int N>
void SgHash< N >::Xor ( const SgHash< N > &  code  ) 

Combine this hash code with the given hash code.

Definition at line 261 of file SgHash.h.

References SgHash< N >::m_code.

Referenced by SgHashUtil::XorInteger(), and SgHashUtil::XorZobrist().


Member Data Documentation

template<int N>
std::bitset<N> SgHash< N >::m_code [private]

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


Sun Mar 13 2011 Doxygen 1.7.1