EvolvingObjects
|
00001 00025 //----------------------------------------------------------------------------- 00026 00027 #ifndef _eoTruncSelect_h 00028 #define _eoTruncSelect_h 00029 00030 00031 //----------------------------------------------------------------------------- 00032 #include <eoSelect.h> 00033 #include <utils/eoHowMany.h> 00034 #include <math.h> 00035 //----------------------------------------------------------------------------- 00036 00044 template<class EOT> 00045 class eoTruncSelect : public eoSelect<EOT> 00046 { 00047 public: 00049 eoTruncSelect(eoSelectOne<EOT>& _select, eoHowMany _howMany) 00050 : select(_select), howMany(_howMany) {} 00051 00058 virtual void operator()(const eoPop<EOT>& _source, eoPop<EOT>& _dest) 00059 { 00060 unsigned target = howMany(_source.size()); 00061 00062 _dest.resize(target); 00063 00064 select.setup(_source); 00065 00066 for (size_t i = 0; i < _dest.size(); ++i) 00067 _dest[i] = select(_source); 00068 } 00069 00070 private : 00071 eoSelectOne<EOT>& select; 00072 eoHowMany howMany; 00073 }; 00074 00075 #endif