1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/stdapis/boost/random/random_number_generator.hpp Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,56 @@
1.4 +/* boost random/random_number_generator.hpp header file
1.5 + *
1.6 + * Copyright Jens Maurer 2000-2001
1.7 + * Distributed under the Boost Software License, Version 1.0. (See
1.8 + * accompanying file LICENSE_1_0.txt or copy at
1.9 + * http://www.boost.org/LICENSE_1_0.txt)
1.10 + *
1.11 + * See http://www.boost.org for most recent version including documentation.
1.12 + *
1.13 + * $Id: random_number_generator.hpp,v 1.5 2004/11/09 21:22:00 jmaurer Exp $
1.14 + *
1.15 + * Revision history
1.16 + * 2001-02-18 moved to individual header files
1.17 + */
1.18 +
1.19 +#ifndef BOOST_RANDOM_RANDOM_NUMBER_GENERATOR_HPP
1.20 +#define BOOST_RANDOM_RANDOM_NUMBER_GENERATOR_HPP
1.21 +
1.22 +#include <boost/config.hpp>
1.23 +#include <boost/limits.hpp>
1.24 +#include <boost/static_assert.hpp>
1.25 +#include <boost/random/uniform_int.hpp>
1.26 +#include <boost/random/variate_generator.hpp>
1.27 +
1.28 +namespace boost {
1.29 +
1.30 +// a model for RandomNumberGenerator std:25.2.11 [lib.alg.random.shuffle]
1.31 +template<class UniformRandomNumberGenerator, class IntType = long>
1.32 +class random_number_generator
1.33 +{
1.34 +public:
1.35 + typedef UniformRandomNumberGenerator base_type;
1.36 + typedef IntType argument_type;
1.37 + typedef IntType result_type;
1.38 + random_number_generator(base_type& rng) : _rng(rng)
1.39 + {
1.40 +#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
1.41 + BOOST_STATIC_ASSERT(std::numeric_limits<result_type>::is_integer);
1.42 +#endif
1.43 + }
1.44 + // compiler-generated copy ctor is fine
1.45 + // assignment is disallowed because there is a reference member
1.46 +
1.47 + result_type operator()(argument_type n)
1.48 + {
1.49 + typedef uniform_int<IntType> dist_type;
1.50 + return variate_generator<base_type&, dist_type>(_rng, dist_type(0, n-1))();
1.51 + }
1.52 +
1.53 +private:
1.54 + base_type& _rng;
1.55 +};
1.56 +
1.57 +} // namespace boost
1.58 +
1.59 +#endif // BOOST_RANDOM_RANDOM_NUMBER_GENERATOR_HPP