X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Ftt.h;h=f2928fb9e84b4b754ae9c1ecfb9a1c01b7778a56;hp=778e5e81bf86dd37ad5725823967ea9ef87b4f0e;hb=0ddf84870ad9f7fb4309e992e1e5eae968577958;hpb=803c8e0be3de7357a27c5fcd6c5580f5399e8389 diff --git a/src/tt.h b/src/tt.h index 778e5e81..f2928fb9 100644 --- a/src/tt.h +++ b/src/tt.h @@ -34,6 +34,39 @@ //// Types //// + +/// A simple fixed size hash table used to store pawns and material +/// configurations. It is basically just an array of Entry objects. +/// Without cluster concept or overwrite policy. + +template +class SimpleHash { + + SimpleHash(const SimpleHash&); + SimpleHash& operator=(const SimpleHash&); + +public: + SimpleHash() { + + entries = new Entry[HashSize]; + if (!entries) + { + std::cerr << "Failed to allocate " << HashSize * sizeof(Entry) + << " bytes for material hash table." << std::endl; + exit(EXIT_FAILURE); + } + memset(entries, 0, HashSize * sizeof(Entry)); + } + + ~SimpleHash() { delete [] entries; } + + Entry* find(Key key) const { return entries + unsigned(key & (HashSize - 1)); } + +protected: + Entry* entries; +}; + + /// The TTEntry class is the class of transposition table entries /// /// A TTEntry needs 128 bits to be stored