Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SgHash< N > Class Template Reference

#include <SgHash.h>

List of all members.


Detailed Description

template<int N>
class SgHash< N >

N-bit hash codes.

Definition at line 27 of file SgHash.h.

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


Constructor & Destructor Documentation

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

Costruct hash code initialized with zero.

Definition at line 31 of file SgHash.h.

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

Construct hash code from integer index.

Definition at line 104 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 36 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 146 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 152 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 158 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 164 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 183 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 190 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 196 of file SgHash.h.

References SgHash< N >::Random().

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

Definition at line 202 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 208 of file SgHash.h.

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

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

Definition at line 140 of file SgHash.h.

References SgHash< N >::m_code.

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

Definition at line 117 of file SgHash.h.

References SgHash< N >::m_code.

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

Definition at line 134 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 220 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 234 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 240 of file SgHash.h.

References SgHash< N >::m_code.

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

Definition at line 246 of file SgHash.h.

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

Convert hash code to string.

Definition at line 252 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 266 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]

Definition at line 97 of file SgHash.h.

Referenced by SgHash< N >::Clear(), SgHash< N >::Code2(), SgHash< N >::FromString(), SgHash< N >::GetWord(), SgHash< N >::IsZero(), SgHash< N >::operator!=(), SgHash< N >::operator<(), SgHash< N >::operator==(), SgHash< N >::Random(), SgHash< N >::RollLeft(), SgHash< N >::RollRight(), SgHash< N >::SgHash(), SgHash< N >::ToString(), and SgHash< N >::Xor().


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


17 Jun 2010 Doxygen 1.4.7