00001 /* twinList.h 00002 */ 00003 #ifndef CHECKMATE_TWINLIST_H 00004 #define CHECKMATE_TWINLIST_H 00005 00006 #include "osl/checkmate/twinEntry.h" 00007 #include "osl/checkmate/checkAssert.h" 00008 #include "osl/stl/slist.h" 00009 #include <iosfwd> 00010 00011 namespace osl 00012 { 00013 namespace checkmate 00014 { 00015 class TwinList : private slist<TwinEntry> 00016 { 00017 unsigned int size_cache; 00018 public: 00019 TwinList() : size_cache(0) 00020 { 00021 } 00022 using slist<TwinEntry>::const_iterator; 00023 using slist<TwinEntry>::begin; 00024 using slist<TwinEntry>::end; 00025 using slist<TwinEntry>::empty; 00026 unsigned int size() const { return size_cache; } 00027 void clear(); 00028 const_iterator find(const PathEncoding& path) const 00029 { 00030 for (const_iterator p=begin(); p!=end(); ++p) 00031 { 00032 if (p->path == path) 00033 return p; 00034 } 00035 return end(); 00036 } 00037 const TwinEntry* findLoopTo(const CheckHashRecord *record) const 00038 { 00039 for (const_iterator p=begin(); p!=end(); ++p) 00040 { 00041 if (p->loopTo == record) 00042 return &*p; 00043 } 00044 return 0; 00045 } 00047 void addLoopDetection(const PathEncoding& path, const CheckMove& move, 00048 const CheckHashRecord *loopTo) 00049 { 00050 check_assert(find(path) == end()); 00051 ++size_cache; 00052 push_front(TwinEntry(path, move, loopTo)); 00053 } 00054 00055 void dump(std::ostream&) const; 00056 }; 00057 } 00058 } 00059 00060 00061 #endif /* CHECKMATE_TWINLIST_H */ 00062 // ;;; Local Variables: 00063 // ;;; mode:c++ 00064 // ;;; c-basic-offset:2 00065 // ;;; End: