STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
uniform_int< _Ty > Class Template Reference
Inheritance diagram for uniform_int< _Ty >:
uniform_int_distribution< _Ty >

Classes

struct  param_type
 

Public Types

typedef uniform_int< _Ty > _Myt
 
typedef _Ty result_type
 

Public Member Functions

 uniform_int (_Ty _Min0=0, _Ty _Max0=9)
 
 uniform_int (const param_type &_Par0)
 
result_type a () const
 
result_type b () const
 
param_type param () const
 
void param (const param_type &_Par0)
 
result_type() min () const
 
result_type() max () const
 
void reset ()
 
template<class _Engine >
result_type operator() (_Engine &_Eng) const
 
template<class _Engine >
result_type operator() (_Engine &_Eng, const param_type &_Par0) const
 
template<class _Engine >
result_type operator() (_Engine &_Eng, result_type _Nx) const
 
template<class _Elem , class _Traits >
basic_istream< _Elem, _Traits > & _Read (basic_istream< _Elem, _Traits > &_Istr)
 
template<class _Elem , class _Traits >
basic_ostream< _Elem, _Traits > & _Write (basic_ostream< _Elem, _Traits > &_Ostr) const
 

Private Types

typedef make_unsigned< _Ty >::type _Uty
 

Private Member Functions

template<class _Engine >
result_type _Eval (_Engine &_Eng, _Ty _Min, _Ty _Max) const
 

Static Private Member Functions

static _Uty _Adjust (_Uty _Uval)
 
static _Uty _Adjust (_Uty _Uval, true_type)
 
static _Uty _Adjust (_Uty _Uval, false_type)
 

Private Attributes

param_type _Par
 

Member Typedef Documentation

template<class _Ty = int>
typedef uniform_int<_Ty> uniform_int< _Ty >::_Myt
template<class _Ty = int>
typedef make_unsigned<_Ty>::type uniform_int< _Ty >::_Uty
private
template<class _Ty = int>
typedef _Ty uniform_int< _Ty >::result_type

Constructor & Destructor Documentation

template<class _Ty = int>
uniform_int< _Ty >::uniform_int ( _Ty  _Min0 = 0,
_Ty  _Max0 = 9 
)
inlineexplicit
2269  : _Par(_Min0, _Max0)
2270  { // construct from parameters
2271  }
param_type _Par
Definition: random:2391
template<class _Ty = int>
uniform_int< _Ty >::uniform_int ( const param_type _Par0)
inlineexplicit
2274  : _Par(_Par0)
2275  { // construct from parameter package
2276  }
param_type _Par
Definition: random:2391

Member Function Documentation

template<class _Ty = int>
static _Uty uniform_int< _Ty >::_Adjust ( _Uty  _Uval)
inlinestaticprivate
2372  { // convert signed ranges to unsigned ranges and vice versa
2373  return (_Adjust(_Uval, is_signed<_Ty>()));
2374  }
static _Uty _Adjust(_Uty _Uval)
Definition: random:2371
Definition: type_traits:799
template<class _Ty = int>
static _Uty uniform_int< _Ty >::_Adjust ( _Uty  _Uval,
true_type   
)
inlinestaticprivate
2377  { // convert signed ranges to unsigned ranges and vice versa
2378  const _Uty _Adjuster = (_Uty(-1) >> 1) + 1; // 2^(N-1)
2379 
2380  if (_Uval < _Adjuster)
2381  return (_Uval + _Adjuster);
2382  else
2383  return (_Uval - _Adjuster);
2384  }
make_unsigned< _Ty >::type _Uty
Definition: random:2351
template<class _Ty = int>
static _Uty uniform_int< _Ty >::_Adjust ( _Uty  _Uval,
false_type   
)
inlinestaticprivate
2387  { // _Ty is already unsigned, do nothing
2388  return (_Uval);
2389  }
template<class _Ty = int>
template<class _Engine >
result_type uniform_int< _Ty >::_Eval ( _Engine &  _Eng,
_Ty  _Min,
_Ty  _Max 
) const
inlineprivate
2355  { // compute next value in range [_Min, _Max]
2356  _Rng_from_urng<_Uty, _Engine> _Rng(_Eng);
2357 
2358  const _Uty _Umin = _Adjust(_Uty(_Min));
2359  const _Uty _Umax = _Adjust(_Uty(_Max));
2360 
2361  _Uty _Uret = 0;
2362 
2363  if (_Umax - _Umin == _Uty(-1))
2364  _Uret = static_cast<_Uty>(_Rng._Get_all_bits());
2365  else
2366  _Uret = static_cast<_Uty>(_Rng(_Umax - _Umin + 1));
2367 
2368  return (_Ty(_Adjust(_Uret + _Umin)));
2369  }
Definition: xutility:3518
make_unsigned< _Ty >::type _Uty
Definition: random:2351
static _Uty _Adjust(_Uty _Uval)
Definition: random:2371
template<class _Ty = int>
template<class _Elem , class _Traits >
basic_istream<_Elem, _Traits>& uniform_int< _Ty >::_Read ( basic_istream< _Elem, _Traits > &  _Istr)
inline
2334  { // read state from _Istr
2335  _Ty _Min0;
2336  _Ty _Max0;
2337  _Istr >> _Min0 >> _Max0;
2338  _Par._Init(_Min0, _Max0);
2339  return (_Istr);
2340  }
void _Init(_Ty _Min0, _Ty _Max0)
Definition: random:2255
param_type _Par
Definition: random:2391
template<class _Ty = int>
template<class _Elem , class _Traits >
basic_ostream<_Elem, _Traits>& uniform_int< _Ty >::_Write ( basic_ostream< _Elem, _Traits > &  _Ostr) const
inline
2346  { // write state to _Ostr
2347  return (_Ostr << _Par._Min << ' ' << _Par._Max);
2348  }
param_type _Par
Definition: random:2391
result_type _Min
Definition: random:2263
result_type _Max
Definition: random:2264
template<class _Ty = int>
result_type uniform_int< _Ty >::a ( ) const
inline
2279  { // return a value
2280  return (_Par.a());
2281  }
param_type _Par
Definition: random:2391
result_type a() const
Definition: random:2245
template<class _Ty = int>
result_type uniform_int< _Ty >::b ( ) const
inline
2284  { // return b value
2285  return (_Par.b());
2286  }
param_type _Par
Definition: random:2391
result_type b() const
Definition: random:2250
template<class _Ty = int>
result_type() uniform_int< _Ty >::max ( ) const
inline
2304  { // return maximum possible generated value
2305  return (_Par._Max);
2306  }
param_type _Par
Definition: random:2391
result_type _Max
Definition: random:2264
template<class _Ty = int>
result_type() uniform_int< _Ty >::min ( ) const
inline
2299  { // return minimum possible generated value
2300  return (_Par._Min);
2301  }
param_type _Par
Definition: random:2391
result_type _Min
Definition: random:2263
template<class _Ty = int>
template<class _Engine >
result_type uniform_int< _Ty >::operator() ( _Engine &  _Eng) const
inline
2314  { // return next value
2315  return (_Eval(_Eng, _Par._Min, _Par._Max));
2316  }
param_type _Par
Definition: random:2391
result_type _Min
Definition: random:2263
result_type _Max
Definition: random:2264
result_type _Eval(_Engine &_Eng, _Ty _Min, _Ty _Max) const
Definition: random:2354
template<class _Ty = int>
template<class _Engine >
result_type uniform_int< _Ty >::operator() ( _Engine &  _Eng,
const param_type _Par0 
) const
inline
2320  { // return next value, given parameter package
2321  return (_Eval(_Eng, _Par0._Min, _Par0._Max));
2322  }
result_type _Eval(_Engine &_Eng, _Ty _Min, _Ty _Max) const
Definition: random:2354
template<class _Ty = int>
template<class _Engine >
result_type uniform_int< _Ty >::operator() ( _Engine &  _Eng,
result_type  _Nx 
) const
inline
2326  { // return next value
2327  return (_Eval(_Eng, 0, _Nx - 1));
2328  }
result_type _Eval(_Engine &_Eng, _Ty _Min, _Ty _Max) const
Definition: random:2354
template<class _Ty = int>
param_type uniform_int< _Ty >::param ( ) const
inline
2289  { // return parameter package
2290  return (_Par);
2291  }
param_type _Par
Definition: random:2391
template<class _Ty = int>
void uniform_int< _Ty >::param ( const param_type _Par0)
inline
2294  { // set parameter package
2295  _Par = _Par0;
2296  }
param_type _Par
Definition: random:2391
template<class _Ty = int>
void uniform_int< _Ty >::reset ( )
inline
2309  { // clear internal state
2310  }

Member Data Documentation

template<class _Ty = int>
param_type uniform_int< _Ty >::_Par
private

The documentation for this class was generated from the following file: