Class template uniform_int_distribution Boost , The Boost C++ Libraries BoostBook Documentation Subset , Reference
Class template uniform_int_distribution
boost::random::uniform_int_distribution
Synopsis
template < typename IntType = int >
class uniform_int_distribution {
public :
typedef IntType input_type ;
typedef IntType result_type ;
class param_type {
public :
typedef uniform_int_distribution distribution_type ;
explicit param_type ( IntType = 0 ,
IntType = ( std :: numeric_limits < IntType > :: max ) ( ) ) ;
IntType a ( ) const ;
IntType b ( ) const ;
template < typename CharT, typename Traits>
friend std :: basic_ostream < CharT , Traits > &
operator << ( std :: basic_ostream < CharT , Traits > & , const param_type & ) ;
template < typename CharT, typename Traits>
friend std :: basic_istream < CharT , Traits > &
operator >> ( std :: basic_istream < CharT , Traits > & , const param_type & ) ;
friend bool operator == ( const param_type & , const param_type & ) ;
friend bool operator != ( const param_type & , const param_type & ) ;
} ;
explicit uniform_int_distribution ( IntType = 0 ,
IntType = ( std :: numeric_limits < IntType > :: max ) ( ) ) ;
explicit uniform_int_distribution ( const param_type & ) ;
IntType min ( ) const ;
IntType max ( ) const ;
IntType a ( ) const ;
IntType b ( ) const ;
param_type param ( ) const ;
void param ( const param_type & ) ;
void reset ( ) ;
template < typename Engine> result_type operator ( ) ( Engine & ) const ;
template < typename Engine>
result_type operator ( ) ( Engine & , const param_type & ) const ;
template < typename CharT, typename Traits>
friend std :: basic_ostream < CharT , Traits > &
operator << ( std :: basic_ostream < CharT , Traits > & ,
const uniform_int_distribution & ) ;
template < typename CharT, typename Traits>
friend std :: basic_istream < CharT , Traits > &
operator >> ( std :: basic_istream < CharT , Traits > & ,
const uniform_int_distribution & ) ;
friend bool operator == ( const uniform_int_distribution & ,
const uniform_int_distribution & ) ;
friend bool operator != ( const uniform_int_distribution & ,
const uniform_int_distribution & ) ;
} ;
Description
Шаблон классаuniform_int_distribution моделируетслучайное распределение . На каждом вызове он возвращает случайное целое значение, равномерно распределенное в наборе целых чисел {min, min+1, min+2, ..., max}.
Параметр шаблона IntType должен обозначать целочисленный тип значения.
uniform_int_distribution
public
construct/copy/destruct
<explicit uniform_int_distribution ( IntType min= 0 ,
IntType max= ( std :: numeric_limits < IntType > :: max ) ( ) ) ; >Построение<uniform_int_distribution
>.<min
>и<max
>являются параметрами распределения.
Требуется: min<= max
<explicit uniform_int_distribution ( const param_type & param) ; >Конструирует<uniform_int_distribution
>из его параметров.
uniform_int_distribution
public member functions
<IntType min ( ) const ; >Возвращает минимальное значение распределения
<IntType max ( ) const ; >Возвращает максимальное значение распределения
<IntType a ( ) const ; >Возвращает минимальное значение распределения
<IntType b ( ) const ; >Возвращает максимальное значение распределения
<param_type param ( ) const ; >Возвращает параметры распределения.
<void param ( const param_type & param) ; >Устанавливает параметры распределения.
<void reset ( ) ; >Эффекты: Последующее использование распределения не зависит от значений, произведенных каким-либо двигателем до вызова сброса.
<template < typename Engine> result_type operator ( ) ( Engine & eng) const ; >Возвращает целое число, равномерно распределенное в диапазоне [мин, макс].
<template < typename Engine>
result_type operator ( ) ( Engine & eng, const param_type & param) const ; >Возвращает целое число, равномерно распределенное в диапазоне [param.a(), param.b()].
uniform_int_distribution
friend functions
<template < typename CharT, typename Traits>
friend std :: basic_ostream < CharT , Traits > &
operator << ( std :: basic_ostream < CharT , Traits > & os,
const uniform_int_distribution & ud) ; >Пишет распределение<std::ostream
>
.
<template < typename CharT, typename Traits>
friend std :: basic_istream < CharT , Traits > &
operator >> ( std :: basic_istream < CharT , Traits > & is,
const uniform_int_distribution & ud) ; >Читает распределение от<std::istream
>
.
<friend bool operator == ( const uniform_int_distribution & lhs,
const uniform_int_distribution & rhs) ; >Возвращается истинно, если два распределения производят одинаковые последовательности значений, заданных равными генераторами.
<friend bool operator != ( const uniform_int_distribution & lhs,
const uniform_int_distribution & rhs) ; >Возвращается истинно, если два распределения могут производить различные последовательности значений, заданных равными генераторами.
Статья Class template uniform_int_distribution раздела The Boost C++ Libraries BoostBook Documentation Subset Reference может быть полезна для разработчиков на c++ и boost.
Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.
:: Главная :: Reference ::