| 1 |
/* twinTable.h |
| 2 |
*/ |
| 3 |
#ifndef _TWIN_HASHTABLE_H |
| 4 |
#define _TWIN_HASHTABLE_H |
| 5 |
|
| 6 |
#include "twinEntry.h" |
| 7 |
#include <boost/scoped_ptr.hpp> |
| 8 |
|
| 9 |
namespace osl |
| 10 |
{ |
| 11 |
class PathEncoding; |
| 12 |
|
| 13 |
namespace checkmate |
| 14 |
{ |
| 15 |
class CheckMoveListProvider; |
| 16 |
/** |
| 17 |
* 詰将棋のGHI対策用テーブル. |
| 18 |
* TwinListに入れなかったものが入る |
| 19 |
*/ |
| 20 |
class TwinTable |
| 21 |
{ |
| 22 |
class Table; |
| 23 |
std::unique_ptr<Table> table; |
| 24 |
public: |
| 25 |
TwinTable(); |
| 26 |
~TwinTable(); |
| 27 |
|
| 28 |
void addTwin(const TwinEntry&); |
| 29 |
void clearTwins(); |
| 30 |
|
| 31 |
const TwinEntry *findTwin(const PathEncoding&) const; |
| 32 |
TwinAgeEntry& allocateTwin(const PathEncoding&); |
| 33 |
size_t size() const; |
| 34 |
}; |
| 35 |
|
| 36 |
class TwinTableHolder : private TwinTable |
| 37 |
{ |
| 38 |
std::unique_ptr<CheckMoveListProvider> list_provider; |
| 39 |
protected: |
| 40 |
~TwinTableHolder(); |
| 41 |
public: |
| 42 |
TwinTableHolder(); |
| 43 |
using TwinTable::addTwin; |
| 44 |
using TwinTable::clearTwins; |
| 45 |
using TwinTable::findTwin; |
| 46 |
using TwinTable::size; |
| 47 |
using TwinTable::allocateTwin; |
| 48 |
|
| 49 |
const TwinTable& getTwinTable() const { return *this; } |
| 50 |
void addLoopDetection(const PathEncoding& path, const CheckMove& move, |
| 51 |
const CheckHashRecord *loopTo) |
| 52 |
{ |
| 53 |
addTwin(TwinEntry(path, move, loopTo)); |
| 54 |
} |
| 55 |
void addLoopDetection(const PathEncoding& path, const CheckHashRecord *loopTo=0) |
| 56 |
{ |
| 57 |
addTwin(TwinEntry(path, CheckMove(), loopTo)); |
| 58 |
} |
| 59 |
CheckMoveListProvider& listProvider() { return *list_provider; } |
| 60 |
void clear(); |
| 61 |
}; |
| 62 |
|
| 63 |
|
| 64 |
} // namespace checkmate |
| 65 |
} // namespace osl |
| 66 |
|
| 67 |
#endif /* _TWIN_HASHTABLE_H_ */ |
| 68 |
// ;;; Local Variables: |
| 69 |
// ;;; mode:c++ |
| 70 |
// ;;; c-basic-offset:2 |
| 71 |
// ;;; End: |