00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef __moSimpleMoveTabuList_h
00013 #define __moSimpleMoveTabuList_h
00014
00015 #include <list>
00016 #include <iterator>
00017
00018 #include "moTabuList.h"
00019
00021 template <class M>
00022 class moSimpleMoveTabuList: public moTabuList < M >
00023 {
00024
00025 public:
00026
00028 typedef typename M::EOType EOT;
00029
00031
00032
00033
00034 moSimpleMoveTabuList(unsigned __size): maxSize(__size)
00035 {
00036 currentSize=0;
00037 }
00038
00040
00045 bool
00046 operator () (const M & __move, const EOT & __sol)
00047 {
00048 typename std::list<M>::iterator it;
00049
00050 it=tabuList.begin();
00051 while(it!=tabuList.end()&&(!((*it)==__move)))
00052 {
00053 it++;
00054 }
00055
00056 return it!=tabuList.end();
00057 }
00058
00059 void
00060 add (const M & __move, const EOT & __sol)
00061 {
00062 if(currentSize!=0)
00063 {
00064
00065
00066 removeMove(__move);
00067 }
00068
00069 tabuList.push_back(__move);
00070
00071 if(currentSize==maxSize)
00072 {
00073 tabuList.erase(tabuList.begin());
00074 }
00075 else
00076 {
00077 currentSize++;
00078 }
00079 }
00080
00081 void
00082 update ()
00083 {
00084
00085 }
00086
00087 void
00088 init ()
00089 {
00090
00091 }
00092
00093 private:
00094
00096
00099 void
00100 removeMove(const M & __move)
00101 {
00102 typename std::list<M>::iterator it;
00103
00104 it=tabuList.begin();
00105 while(it!=tabuList.end()&&(!((*it)==__move)))
00106 {
00107 it++;
00108 }
00109
00110 if(it!=tabuList.end())
00111 {
00112 tabuList.erase(it);
00113 }
00114 }
00115
00117 unsigned maxSize;
00118
00120 unsigned currentSize;
00121
00123 std::list<M> tabuList;
00124 };
00125
00126 #endif