moSimpleMoveTabuList.h

00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
00002 
00003 // "moSimpleMoveTabuList.h"
00004 
00005 // (c) OPAC Team, LIFL, 2003-2007
00006 
00007 /* LICENCE TEXT 
00008    
00009    Contact: paradiseo-help@lists.gforge.inria.fr
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     \param __size The maximum size of the move tabu list.
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     tabuList.push_back(__move);
00063     
00064     if(currentSize==maxSize)
00065       {
00066         tabuList.erase(tabuList.begin());
00067       }
00068     else
00069       {
00070         currentSize++;
00071       }
00072   }
00073   
00074   void
00075   update ()
00076   {
00077     //nothing to do
00078   }
00079 
00080   void
00081   init ()
00082   {
00083     //nothing to do
00084   }
00085 
00086 private:
00087   
00089   unsigned maxSize;
00090 
00092   unsigned currentSize;
00093   
00095   std::list<M> tabuList;
00096 };
00097 
00098 #endif

Generated on Thu Apr 19 15:16:09 2007 for PARADISEO-MO by  doxygen 1.5.1