From a8bf667774b4224e45699418a6ad35b120e8d14e Mon Sep 17 00:00:00 2001 From: evomarc Date: Tue, 16 Jan 2001 05:52:01 +0000 Subject: [PATCH] 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) --- eo/src/utils/rnd_generators.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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