1 /***************************************************************************
2 hash.h - Hash related definitions
4 begin : Sun Sep 28 2007
5 copyright : (C) 2007 by Maurizio Monge
6 email : monge@linuz.sns.it
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
23 /* Yes, 96 bits hash keys.
24 the 'index' field is used as index in the hashtable,
25 the 'check' field to check the indexed position.
26 Now, i don't want event to think about possible key collisions :) */
41 HashKey(uint64_t c
, uint32_t i
= 0) :
43 HashKey(uint32_t ch
, uint32_t cl
, uint32_t i
) :
44 check_lo(cl
), check_hi(ch
), index(i
) {}
46 HashKey
operator^(const HashKey
& h
) const {
47 return HashKey(check
^ h
.check
, index
^ h
.index
); }
48 const HashKey
& operator^=(const HashKey
& h
) {
53 bool operator==(const HashKey
& h
) const {
54 return (check
== h
.check
) && (index
== h
.index
); }
55 bool operator!=(const HashKey
& h
) const {
56 return (check
!= h
.check
) || (index
!= h
.index
); }
57 bool operator<(const HashKey
& h
) const {
58 return check
<h
.check
? true :
59 (check
==h
.check
&& index
<h
.index
) ? true :
62 char* to_string(char*) const;
65 /* An entry in the hashtable */
66 class PACKED HashEntry
69 /* field to verify the entry against a position */
73 uint8_t no_good_moves
: 1;
74 uint16_t best_mv
: 14;
78 int16_t lower(){ return lo
; }
79 int16_t upper(){ return up
; }