Added the eoRandomReduce class - hence I also added the shuffle method

in eoPop (I had been postponing that for a long time!) which in turn required
another class of random generator (whose operator() takes an unsigned as argument)
This commit is contained in:
evomarc 2001-01-16 05:52:01 +00:00
commit a8bf667774

View file

@ -112,6 +112,23 @@ bool random_generator<bool>::operator()(void)
return random.flip(0.5);
}
/**
Another class random_generator that can be used in the STL random_shuffle
function (see eoPop::shuffle): its operator() takes an unsigned argument m
and must return an unsigned uniformly distributed in [0,m}
*/
template <class T = uint32> class UF_random_generator
{
public :
UF_random_generator(eoRng& _rng = rng) :
random(_rng) {}
T operator()(T _t) { return (T) (random.random(_t)); }
private :
eoRng& random;
};
/**
The class normal_generator can be used in the STL generate function