...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::random::discrete_distribution::param_type
// In header: <boost/random/discrete_distribution.hpp> class param_type { public: // types typedef discrete_distribution distribution_type; // public member functions param_type(); template<typename Iter> param_type(Iter, Iter); param_type(const std::initializer_list< WeightType > &); template<typename Range> explicit param_type(const Range &); template<typename Func> param_type(std::size_t, double, double, Func); std::vector< WeightType > probabilities() const; // friend functions template<typename CharT, typename Traits> std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > &, const param_type &); template<typename CharT, typename Traits> std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > &, const param_type &); bool operator==(const param_type &, const param_type &); bool operator!=(const param_type &, const param_type &); };
param_type
public member functionsparam_type();
Constructs a param_type
object, representing a distribution with and .
template<typename Iter> param_type(Iter first, Iter last);
If first
== last
, equivalent to the default constructor. Otherwise, the values of the range represent weights for the possible values of the distribution.
param_type(const std::initializer_list< WeightType > & wl);
If wl.size() == 0, equivalent to the default constructor. Otherwise, the values of the initializer_list
represent weights for the possible values of the distribution.
template<typename Range> explicit param_type(const Range & range);
If the range is empty, equivalent to the default constructor. Otherwise, the elements of the range represent weights for the possible values of the distribution.
template<typename Func> param_type(std::size_t nw, double xmin, double xmax, Func fw);
If nw is zero, equivalent to the default constructor. Otherwise, the range of the distribution is [0, nw), and the weights are found by calling fw with values evenly distributed between and , where .
std::vector< WeightType > probabilities() const;
Returns a vector containing the probabilities of each possible value of the distribution.
param_type
friend functionstemplate<typename CharT, typename Traits> std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > & os, const param_type & param);
Writes the parameters to a std::ostream
.
template<typename CharT, typename Traits> std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > & is, const param_type & param);
Reads the parameters from a std::istream
.
bool operator==(const param_type & lhs, const param_type & rhs);
Returns true if the two sets of parameters are the same.
bool operator!=(const param_type & lhs, const param_type & rhs);
Returns true if the two sets of parameters are different.