00001 /* lRUMoves.h 00002 */ 00003 #ifndef OSL_SEARCH_LRUMOVES_H 00004 #define OSL_SEARCH_LRUMOVES_H 00005 00006 #include "osl/move.h" 00007 #include "osl/misc/carray.h" 00008 #ifdef OSL_SMP 00009 # include "osl/misc/lightMutex.h" 00010 #endif 00011 00012 namespace osl 00013 { 00014 namespace search 00015 { 00016 class LRUMoves 00017 { 00018 typedef CArray<Move, 2> moves_t; 00019 moves_t moves; 00020 #ifdef OSL_SMP 00021 typedef osl::misc::LightMutex Mutex; 00022 mutable Mutex mutex; 00023 #endif 00024 public: 00025 LRUMoves() {} 00026 LRUMoves(const LRUMoves& src) 00027 : moves(src.moves) 00028 { 00029 } 00030 LRUMoves& operator=(const LRUMoves& src) 00031 { 00032 if (this != &src) 00033 moves = src.moves; 00034 return *this; 00035 } 00036 00037 void clear() 00038 { 00039 #ifdef OSL_SMP 00040 Mutex::scoped_lock lk(mutex); 00041 #endif 00042 moves.fill(Move::INVALID()); 00043 } 00044 void setMove(Move best_move) 00045 { 00046 #ifdef OSL_SMP 00047 Mutex::scoped_lock lk(mutex); 00048 #endif 00049 if (best_move.isNormal() && moves[0] != best_move) 00050 { 00051 moves[1] = moves[0]; 00052 moves[0] = best_move; 00053 } 00054 } 00055 const Move operator[](size_t i) const 00056 { 00057 return moves[i]; 00058 } 00059 static size_t size() { return moves_t::size(); } 00060 }; 00061 } 00062 } // namespace osl 00063 00064 #endif /* OSL_SEARCH_LRUMOVES_H */ 00065 // ;;; Local Variables: 00066 // ;;; mode:c++ 00067 // ;;; c-basic-offset:2 00068 // ;;; End: