EvolvingObjects
eoSelectNumber.h
00001 
00023 //-----------------------------------------------------------------------------
00024 
00025 #ifndef _eoSelectNumber_h
00026 #define _eoSelectNumber_h
00027 
00028 
00029 //-----------------------------------------------------------------------------
00030 #include <eoSelect.h>
00031 #include <eoSelectOne.h>
00032 #include <math.h>
00033 //-----------------------------------------------------------------------------
00034 
00043 template<class EOT>
00044 class eoSelectNumber : public eoSelect<EOT>
00045 {
00046  public:
00048      eoSelectNumber(eoSelectOne<EOT>& _select, unsigned _nb_to_select = 1)
00049          : select(_select), nb_to_select(_nb_to_select) {}
00050 
00057   virtual void operator()(const eoPop<EOT>& _source, eoPop<EOT>& _dest)
00058   {
00059     size_t target = static_cast<size_t>(nb_to_select);
00060 
00061     _dest.resize(target);
00062 
00063     select.setup(_source);
00064 
00065     for (size_t i = 0; i < _dest.size(); ++i)
00066       _dest[i] = select(_source);
00067   }
00068 
00069 private :
00070   eoSelectOne<EOT>& select;
00071   unsigned nb_to_select;
00072 };
00073 
00074 #endif
 All Classes Namespaces Files Functions Variables Typedefs Friends