Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | Related Pages | Search for

# eoTruncSelect.h

    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
    00042 template<class EOT>
    00043 class eoTruncSelect : public eoSelect<EOT>
    00044 {
    00045  public:
    00047   eoTruncSelect(eoSelectOne<EOT>& _select, eoHowMany _howMany)
    00048     : select(_select), howMany(_howMany) {}
    00049
    00056   virtual void operator()(const eoPop<EOT>& _source, eoPop<EOT>& _dest)
    00057   {
    00058     unsigned target = howMany(_source.size());
    00059
    00060     _dest.resize(target);
    00061
    00062     select.setup(_source);
    00063
    00064     for (size_t i = 0; i < _dest.size(); ++i)
    00065       _dest[i] = select(_source);
    00066   }
    00067
    00068 private :
    00069   eoSelectOne<EOT>& select;
    00070   eoHowMany howMany;
    00071 };
    00072
    00073 #endif