File indexing completed on 2025-01-18 09:51:13
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef BOOST_RANDOM_UNIFORM_INT_HPP
0018 #define BOOST_RANDOM_UNIFORM_INT_HPP
0019
0020 #include <boost/assert.hpp>
0021 #include <boost/random/uniform_int_distribution.hpp>
0022
0023 namespace boost {
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 template<class IntType = int>
0036 class uniform_int : public random::uniform_int_distribution<IntType>
0037 {
0038 typedef random::uniform_int_distribution<IntType> base_type;
0039 public:
0040
0041 class param_type : public base_type::param_type
0042 {
0043 public:
0044 typedef uniform_int distribution_type;
0045
0046
0047
0048
0049
0050 explicit param_type(IntType min_arg = 0, IntType max_arg = 9)
0051 : base_type::param_type(min_arg, max_arg)
0052 {}
0053 };
0054
0055
0056
0057
0058
0059
0060
0061 explicit uniform_int(IntType min_arg = 0, IntType max_arg = 9)
0062 : base_type(min_arg, max_arg)
0063 {}
0064
0065
0066 explicit uniform_int(const param_type& parm)
0067 : base_type(parm)
0068 {}
0069
0070
0071 param_type param() const { return param_type(this->a(), this->b()); }
0072
0073 void param(const param_type& parm) { this->base_type::param(parm); }
0074
0075
0076
0077 template<class Engine>
0078 IntType operator()(Engine& eng) const
0079 {
0080 return static_cast<const base_type&>(*this)(eng);
0081 }
0082
0083 template<class Engine>
0084 IntType operator()(Engine& eng, const param_type& parm) const
0085 {
0086 return static_cast<const base_type&>(*this)(eng, parm);
0087 }
0088
0089 template<class Engine>
0090 IntType operator()(Engine& eng, IntType n) const
0091 {
0092 BOOST_ASSERT(n > 0);
0093 return static_cast<const base_type&>(*this)(eng, param_type(0, n - 1));
0094 }
0095 };
0096
0097 }
0098
0099 #endif