00001 /* checkMoveList.h 00002 */ 00003 #ifndef _CHECK_MOVELIST_H 00004 #define _CHECK_MOVELIST_H 00005 00006 #include "osl/checkmate/checkMove.h" 00007 #include "osl/stl/vector.h" 00008 #include <cassert> 00009 #include <iosfwd> 00010 00011 namespace osl 00012 { 00013 namespace checkmate 00014 { 00015 class CheckMoveListProvider; 00016 class CheckMoveListBase 00017 { 00018 CheckMove *first, *last; 00019 public: 00020 CheckMoveListBase() : first(0), last(0) 00021 { 00022 } 00023 00024 void setSize(size_t length, CheckMoveListProvider&); 00025 void shrinkSize(size_t length) 00026 { 00027 assert(length <= static_cast<size_t>(last - first)); 00028 last = first + length; 00029 } 00030 void setOne(const CheckMove& data, CheckMoveListProvider&); 00031 00032 typedef const CheckMove* const_iterator; 00033 typedef CheckMove* iterator; 00034 00035 CheckMove *begin() { return first; } 00036 CheckMove *end() { return last; } 00037 00038 const CheckMove *begin() const { return first; } 00039 const CheckMove *end() const { return last; } 00040 00041 CheckMove& operator[](size_t i) { 00042 assert(first+i<last); return first[i]; 00043 } 00044 const CheckMove& operator[](size_t i) const { 00045 assert(first+i<last); return first[i]; 00046 } 00047 00048 void clear() { first = last = 0; } 00049 00050 size_t size() const { return last - first; } 00051 bool empty() const { return last == first; } 00052 }; 00056 class CheckMoveList : public CheckMoveListBase 00057 { 00058 public: 00059 const CheckMove* find(Move move) const; 00060 CheckMove* find(Move move); 00061 void dump(std::ostream&) const; 00062 }; 00063 00064 std::ostream& operator<<(std::ostream&, const CheckMoveList&); 00065 } // namespace checkmate 00066 } // namespace osl 00067 00068 #endif /* _CHECK_MOVELIST_H */ 00069 // ;;; Local Variables: 00070 // ;;; mode:c++ 00071 // ;;; c-basic-offset:2 00072 // ;;; End: