diff --git a/eo/src/utils/rnd_generators.h b/eo/src/utils/rnd_generators.h index eabb0262..7c43b90d 100644 --- a/eo/src/utils/rnd_generators.h +++ b/eo/src/utils/rnd_generators.h @@ -112,6 +112,23 @@ bool random_generator::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 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