Debian Codegraph @

old-sample/legacy-checkmate/lib/twinList.h

raw
1 /* twinList.h
2 */
3 #ifndef CHECKMATE_TWINLIST_H
4 #define CHECKMATE_TWINLIST_H
5
6 #include "twinEntry.h"
7 #include "checkAssert.h"
8 #include "osl/stl/slist.h"
9 #include <iosfwd>
10
11 namespace osl
12 {
13 namespace checkmate
14 {
15 class TwinList : private slist<TwinEntry>
16 {
17 unsigned int size_cache;
18 public:
19 TwinList() : size_cache(0)
20 {
21 }
22 using slist<TwinEntry>::const_iterator;
23 using slist<TwinEntry>::begin;
24 using slist<TwinEntry>::end;
25 using slist<TwinEntry>::empty;
26 unsigned int size() const { return size_cache; }
27 void clear();
28 const_iterator find(const PathEncoding& path) const
29 {
30 for (const_iterator p=begin(); p!=end(); ++p)
31 {
32 if (p->path == path)
33 return p;
34 }
35 return end();
36 }
37 const TwinEntry* findLoopTo(const CheckHashRecord *record) const
38 {
39 for (const_iterator p=begin(); p!=end(); ++p)
40 {
41 if (p->loopTo == record)
42 return &*p;
43 }
44 return 0;
45 }
46 /** @param move 受方の場合のloopに導く手 */
47 void addLoopDetection(const PathEncoding& path, const CheckMove& move,
48 const CheckHashRecord *loopTo)
49 {
50 check_assert(find(path) == end());
51 ++size_cache;
52 push_front(TwinEntry(path, move, loopTo));
53 }
54
55 void dump(std::ostream&) const;
56 };
57 }
58 }
59
60
61 #endif /* CHECKMATE_TWINLIST_H */
62 // ;;; Local Variables:
63 // ;;; mode:c++
64 // ;;; c-basic-offset:2
65 // ;;; End: