Debian Codegraph @

old-sample/legacy-checkmate/lib/checkMoveList.cc

raw
1 /* checkMoveList.cc
2 */
3 #include "checkMoveList.h"
4 #include "checkMoveListProvider.h"
5 #include "checkHashRecord.h"
6 #include <iostream>
7
8 #ifndef MINIMAL
9 std::ostream& osl::checkmate::
10 operator<<(std::ostream& os, const CheckMoveList& l)
11 {
12 for (CheckMoveList::const_iterator p=l.begin(); p!=l.end(); ++p)
13 {
14 os << p->move << " ";
15 }
16 return os << "\n";
17 }
18 #endif
19 /* ------------------------------------------------------------------------- */
20
21 void osl::checkmate::
22 CheckMoveListBase::setSize(size_t length, CheckMoveListProvider& src)
23 {
24 first = src.alloc(length);
25 last = first + length;
26 }
27
28 void osl::checkmate::
29 CheckMoveListBase::setOne(const CheckMove& data, CheckMoveListProvider& src)
30 {
31 if (first == last)
32 setSize(1, src);
33 *first = data;
34 }
35
36 /* ------------------------------------------------------------------------- */
37
38 const osl::checkmate::CheckMove* osl::checkmate::
39 CheckMoveList::find(Move move) const
40 {
41 for (const_iterator p=begin(); p!=end(); ++p)
42 {
43 if (p->move == move)
44 return &*p;
45 }
46 return 0;
47 }
48
49 osl::checkmate::CheckMove* osl::checkmate::
50 CheckMoveList::find(Move move)
51 {
52 for (iterator p=begin(); p!=end(); ++p)
53 {
54 if (p->move == move)
55 return &*p;
56 }
57 return 0;
58 }
59
60 #ifndef MINIMAL
61 void osl::checkmate::
62 CheckMoveList::dump(std::ostream& os) const
63 {
64 os << "moves size " << size() << "\n";
65 for (const_iterator p=begin(); p!=end(); ++p)
66 {
67 os << "moves " << p->flags << " " << p->move;
68 if (p->record)
69 {
70 os << " " << p->record->proofDisproof()
71 << " " << p->record << " parent " << p->record->parent;
72 }
73 else
74 {
75 os << " h " << (int)p->h_proof << " " << (int)p->h_disproof
76 << " c " << (int)p->cost_proof << " " << (int)p->cost_disproof;
77 }
78 os << "\n";
79 }
80 }
81 #endif
82 /* ------------------------------------------------------------------------- */
83 // ;;; Local Variables:
84 // ;;; mode:c++
85 // ;;; c-basic-offset:2
86 // ;;; End: