| 1 |
/* checkMoveList.h |
| 2 |
*/ |
| 3 |
#ifndef _CHECK_MOVELIST_H |
| 4 |
#define _CHECK_MOVELIST_H |
| 5 |
|
| 6 |
#include "checkMove.h" |
| 7 |
#include "osl/stl/vector.h" |
| 8 |
#include <cassert> |
| 9 |
#include <iosfwd> |
| 10 |
|
| 11 |
namespace osl |
| 12 |
{ |
| 13 |
namespace checkmate |
| 14 |
{ |
| 15 |
class CheckMoveListProvider; |
| 16 |
class CheckMoveListBase |
| 17 |
{ |
| 18 |
CheckMove *first, *last; |
| 19 |
public: |
| 20 |
CheckMoveListBase() : first(0), last(0) |
| 21 |
{ |
| 22 |
} |
| 23 |
|
| 24 |
void setSize(size_t length, CheckMoveListProvider&); |
| 25 |
void shrinkSize(size_t length) |
| 26 |
{ |
| 27 |
assert(length <= static_cast<size_t>(last - first)); |
| 28 |
last = first + length; |
| 29 |
} |
| 30 |
void setOne(const CheckMove& data, CheckMoveListProvider&); |
| 31 |
|
| 32 |
typedef const CheckMove* const_iterator; |
| 33 |
typedef CheckMove* iterator; |
| 34 |
|
| 35 |
CheckMove *begin() { return first; } |
| 36 |
CheckMove *end() { return last; } |
| 37 |
|
| 38 |
const CheckMove *begin() const { return first; } |
| 39 |
const CheckMove *end() const { return last; } |
| 40 |
|
| 41 |
CheckMove& operator[](size_t i) { |
| 42 |
assert(first+i<last); return first[i]; |
| 43 |
} |
| 44 |
const CheckMove& operator[](size_t i) const { |
| 45 |
assert(first+i<last); return first[i]; |
| 46 |
} |
| 47 |
|
| 48 |
void clear() { first = last = 0; } |
| 49 |
|
| 50 |
size_t size() const { return last - first; } |
| 51 |
bool empty() const { return last == first; } |
| 52 |
}; |
| 53 |
/** |
| 54 |
* 詰将棋で使う指手 |
| 55 |
*/ |
| 56 |
class CheckMoveList : public CheckMoveListBase |
| 57 |
{ |
| 58 |
public: |
| 59 |
const CheckMove* find(Move move) const; |
| 60 |
CheckMove* find(Move move); |
| 61 |
void dump(std::ostream&) const; |
| 62 |
}; |
| 63 |
|
| 64 |
std::ostream& operator<<(std::ostream&, const CheckMoveList&); |
| 65 |
} // namespace checkmate |
| 66 |
} // namespace osl |
| 67 |
|
| 68 |
#endif /* _CHECK_MOVELIST_H */ |
| 69 |
// ;;; Local Variables: |
| 70 |
// ;;; mode:c++ |
| 71 |
// ;;; c-basic-offset:2 |
| 72 |
// ;;; End: |