-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathegtb_queue.h
34 lines (27 loc) · 877 Bytes
/
egtb_queue.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
#ifndef __EGTB_QUEUE_H__
#define __EGTB_QUEUE_H__
/**
* Class that stores solved but unexpanded positions during the generation of
* a particular table. Since the table is generated in breadth-first order
* using retrograde analysis, open positions are stored in a circular buffer.
*
* Each element stores a board's EGTB code and index.
*/
typedef struct {
unsigned code, index;
} EgtbQueueElement;
class EgtbQueue {
EgtbQueueElement* queue;
int size; // maximum number of elements
int head, tail; // indices of first used slot and first free slot
int enqTotal, deqTotal; // total number of elements enqueued and dequeued
static const int LOG_EVERY = 1 << 22;
public:
EgtbQueue(int size);
~EgtbQueue();
void enqueue(unsigned code, unsigned index);
void dequeue(unsigned* code, unsigned* index);
bool isEmpty();
int getTotal();
};
#endif