From 47447c47650d55102c11464b5ce532dcabdce0d9 Mon Sep 17 00:00:00 2001 From: nojhan Date: Mon, 26 Mar 2012 18:15:45 +0200 Subject: [PATCH] inherit eoCombinedContinue from std::vector, instead of having it as a member, so that we can easily manipulate continuators themselves --- eo/src/eoCombinedContinue.h | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/eo/src/eoCombinedContinue.h b/eo/src/eoCombinedContinue.h index 4dac4d69..5226e28d 100644 --- a/eo/src/eoCombinedContinue.h +++ b/eo/src/eoCombinedContinue.h @@ -19,6 +19,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Contact: todos@geneura.ugr.es, http://geneura.ugr.es +Authors : + todos@geneura.ugr.es + Marc Schoenauer + Ramón Casero Cañas + Johann Dréo */ //----------------------------------------------------------------------------- @@ -40,7 +45,7 @@ @ingroup Combination */ template< class EOT> -class eoCombinedContinue: public eoContinue { +class eoCombinedContinue: public eoContinue, public std::vector* > { public: /// Define Fitness @@ -48,45 +53,45 @@ public: /// Ctor, make sure that at least on continuator is present eoCombinedContinue( eoContinue& _cont) - : eoContinue () + : eoContinue(), std::vector* >(1, &_cont) { - continuators.push_back(&_cont); } /// Ctor - for historical reasons ... should disspear some day eoCombinedContinue( eoContinue& _cont1, eoContinue& _cont2) - : eoContinue () + : eoContinue(), std::vector* >() { - continuators.push_back(&_cont1); - continuators.push_back(&_cont2); +#pragma message "The double continuators constructor of eocombinedContinue is deprecated and will be removed in the next release." + + this->push_back(&_cont1); + this->push_back(&_cont2); } void add(eoContinue & _cont) { - continuators.push_back(&_cont); + this->push_back(&_cont); } - ///////////// RAMON'S CODE /////////////// void removeLast(void) { - continuators.pop_back(); +#pragma message "The removeLast method of eocombinedContinue is deprecated and will be removed in the next release, use pop_back instead." + this->pop_back(); } - ///////////// RAMON'S CODE (end) /////////////// /** Returns false when one of the embedded continuators say so (logical and) */ virtual bool operator() ( const eoPop& _pop ) { - for (unsigned i = 0; i < continuators.size(); ++i) - if ( !(*continuators[i])(_pop) ) return false; + for (unsigned i = 0; i < this->size(); ++i) + if ( ! (*this->at(i))(_pop) ) return false; return true; } virtual std::string className(void) const { return "eoCombinedContinue"; } -private: - std::vector*> continuators; +//private: +// std::vector*> continuators; }; #endif