Changed Maarten's 2-continuator construct into a vector of pointer,

as in all other Combined constructs in EO.
Kept the construtor with 2 eoCOntinue for backward compatibility.
Added of course the add method!
This commit is contained in:
evomarc 2000-11-24 17:26:22 +00:00
commit 3ec57ed93f

View file

@ -28,31 +28,52 @@
#include <eoContinue.h> #include <eoContinue.h>
/** /**
Fitness continuation: Combined continuators - logical AND:
Continues until one of the embedded continuators says halt! Continues until one of the embedded continuators says halt!
20/11/00 MS: Changed the 2-continuator construct to a vector<eoContinue<EOT> >
to be consistent with other Combined constructs
and allow to easily handle more than 2 continuators
*/ */
template< class EOT> template< class EOT>
class eoCombinedContinue: public eoContinue<EOT> { class eoCombinedContinue: public eoContinue<EOT> {
public: public:
/// Define Fitness /// Define Fitness
typedef typename EOT::Fitness FitnessType; typedef typename EOT::Fitness FitnessType;
/// Ctor /// Ctor
eoCombinedContinue( eoContinue<EOT>& _arg1, eoContinue<EOT>& _arg2) eoCombinedContinue( eoContinue<EOT>& _cont)
: eoContinue<EOT> (), arg1(_arg1), arg2(_arg2) {}; : eoContinue<EOT> ()
{
continuators.push_back(&_cont);
}
/** Returns false when one of the embedded continuators say so (logical and) /// Ctor - for historical reasons ... should disspear some day
*/ eoCombinedContinue( eoContinue<EOT>& _cont1, eoContinue<EOT>& _cont2)
virtual bool operator() ( const eoPop<EOT>& _pop ) : eoContinue<EOT> ()
{ {
return arg1(_pop) && arg2(_pop); continuators.push_back(&_cont1);
} continuators.push_back(&_cont2);
}
void add(eoContinue<EOT> & _cont)
{
continuators.push_back(&_cont);
}
/** Returns false when one of the embedded continuators say so (logical and)
*/
virtual bool operator() ( const eoPop<EOT>& _pop )
{
for (unsigned i = 0; i < continuators.size(); ++i)
if ( !(*continuators[i])(_pop) ) return false;
return true;
}
private: private:
eoContinue<EOT>& arg1; std::vector<eoContinue<EOT>*> continuators;
eoContinue<EOT>& arg2;
}; };
#endif #endif