-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathegtb_hash.h
35 lines (25 loc) · 940 Bytes
/
egtb_hash.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef __EGTB_HASH_H__
#define __EGTB_HASH_H__
/**
* A hash set for EGTB position indices. Designed for storing on the order of
* 10-100 values, typically child positions generated from a parent position.
* Due to this particularity, stored indices will often differ only in a few
* bits.
*/
class EgtbHash {
static const int BUCKETS = 64;
static const int BUCKET_SIZE = 50;
static const unsigned MULT = 83; // Knuth's multiplicative function
unsigned data[BUCKETS][BUCKET_SIZE + 1]; // elements go here; allow for sentinels
unsigned bucketCount[BUCKETS]; // number of elements added to each bucket
unsigned dest[BUCKETS * BUCKET_SIZE]; // bucket where each element went
unsigned count; // number of elements added
public:
EgtbHash();
void clear();
void add(unsigned index);
bool contains(unsigned index);
private:
unsigned hash(unsigned index);
};
#endif