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
2235  : _Par(_Min0, _Max0)
2236  { // construct from parameters
2237  }
param_type _Par
Definition: random:2357
template<class _Ty = int>
uniform_int< _Ty >::uniform_int ( const param_type _Par0)
inlineexplicit
2240  : _Par(_Par0)
2241  { // construct from parameter package
2242  }
param_type _Par
Definition: random:2357

Member Function Documentation

template<class _Ty = int>
static _Uty uniform_int< _Ty >::_Adjust ( _Uty  _Uval)
inlinestaticprivate
2338  { // convert signed ranges to unsigned ranges and vice versa
2339  return (_Adjust(_Uval, is_signed<_Ty>()));
2340  }
static _Uty _Adjust(_Uty _Uval)
Definition: random:2337
Definition: type_traits:728
template<class _Ty = int>
static _Uty uniform_int< _Ty >::_Adjust ( _Uty  _Uval,
true_type   
)
inlinestaticprivate
2343  { // convert signed ranges to unsigned ranges and vice versa
2344  const _Uty _Adjuster = (_Uty(-1) >> 1) + 1; // 2^(N-1)
2345 
2346  if (_Uval < _Adjuster)
2347  return (_Uval + _Adjuster);
2348  else
2349  return (_Uval - _Adjuster);
2350  }
make_unsigned< _Ty >::type _Uty
Definition: random:2317
template<class _Ty = int>
static _Uty uniform_int< _Ty >::_Adjust ( _Uty  _Uval,
false_type   
)
inlinestaticprivate
2353  { // _Ty is already unsigned, do nothing
2354  return (_Uval);
2355  }
template<class _Ty = int>
template<class _Engine >
result_type uniform_int< _Ty >::_Eval ( _Engine &  _Eng,
_Ty  _Min,
_Ty  _Max 
) const
inlineprivate
2321  { // compute next value in range [_Min, _Max]
2322  _Rng_from_urng<_Uty, _Engine> _Rng(_Eng);
2323 
2324  const _Uty _Umin = _Adjust(_Uty(_Min));
2325  const _Uty _Umax = _Adjust(_Uty(_Max));
2326 
2327  _Uty _Uret = 0;
2328 
2329  if (_Umax - _Umin == _Uty(-1))
2330  _Uret = static_cast<_Uty>(_Rng._Get_all_bits());
2331  else
2332  _Uret = static_cast<_Uty>(_Rng(_Umax - _Umin + 1));
2333 
2334  return (_Ty(_Adjust(_Uret + _Umin)));
2335  }
Definition: xutility:3635
make_unsigned< _Ty >::type _Uty
Definition: random:2317
static _Uty _Adjust(_Uty _Uval)
Definition: random:2337
template<class _Ty = int>
template<class _Elem , class _Traits >
basic_istream<_Elem, _Traits>& uniform_int< _Ty >::_Read ( basic_istream< _Elem, _Traits > &  _Istr)
inline
2300  { // read state from _Istr
2301  _Ty _Min0;
2302  _Ty _Max0;
2303  _Istr >> _Min0 >> _Max0;
2304  _Par._Init(_Min0, _Max0);
2305  return (_Istr);
2306  }
void _Init(_Ty _Min0, _Ty _Max0)
Definition: random:2221
param_type _Par
Definition: random:2357
template<class _Ty = int>
template<class _Elem , class _Traits >
basic_ostream<_Elem, _Traits>& uniform_int< _Ty >::_Write ( basic_ostream< _Elem, _Traits > &  _Ostr) const
inline
2312  { // write state to _Ostr
2313  return (_Ostr << _Par._Min << ' ' << _Par._Max);
2314  }
param_type _Par
Definition: random:2357
result_type _Min
Definition: random:2229
result_type _Max
Definition: random:2230
template<class _Ty = int>
result_type uniform_int< _Ty >::a ( ) const
inline
2245  { // return a value
2246  return (_Par.a());
2247  }
param_type _Par
Definition: random:2357
result_type a() const
Definition: random:2211
template<class _Ty = int>
result_type uniform_int< _Ty >::b ( ) const
inline
2250  { // return b value
2251  return (_Par.b());
2252  }
param_type _Par
Definition: random:2357
result_type b() const
Definition: random:2216
template<class _Ty = int>
result_type() uniform_int< _Ty >::max ( ) const
inline
2270  { // return maximum possible generated value
2271  return (_Par._Max);
2272  }
param_type _Par
Definition: random:2357
result_type _Max
Definition: random:2230
template<class _Ty = int>
result_type() uniform_int< _Ty >::min ( ) const
inline
2265  { // return minimum possible generated value
2266  return (_Par._Min);
2267  }
param_type _Par
Definition: random:2357
result_type _Min
Definition: random:2229
template<class _Ty = int>
template<class _Engine >
result_type uniform_int< _Ty >::operator() ( _Engine &  _Eng) const
inline
2280  { // return next value
2281  return (_Eval(_Eng, _Par._Min, _Par._Max));
2282  }
param_type _Par
Definition: random:2357
result_type _Min
Definition: random:2229
result_type _Max
Definition: random:2230
result_type _Eval(_Engine &_Eng, _Ty _Min, _Ty _Max) const
Definition: random:2320
template<class _Ty = int>
template<class _Engine >
result_type uniform_int< _Ty >::operator() ( _Engine &  _Eng,
const param_type _Par0 
) const
inline
2286  { // return next value, given parameter package
2287  return (_Eval(_Eng, _Par0._Min, _Par0._Max));
2288  }
result_type _Eval(_Engine &_Eng, _Ty _Min, _Ty _Max) const
Definition: random:2320
template<class _Ty = int>
template<class _Engine >
result_type uniform_int< _Ty >::operator() ( _Engine &  _Eng,
result_type  _Nx 
) const
inline
2292  { // return next value
2293  return (_Eval(_Eng, 0, _Nx - 1));
2294  }
result_type _Eval(_Engine &_Eng, _Ty _Min, _Ty _Max) const
Definition: random:2320
template<class _Ty = int>
param_type uniform_int< _Ty >::param ( ) const
inline
2255  { // return parameter package
2256  return (_Par);
2257  }
param_type _Par
Definition: random:2357
template<class _Ty = int>
void uniform_int< _Ty >::param ( const param_type _Par0)
inline
2260  { // set parameter package
2261  _Par = _Par0;
2262  }
param_type _Par
Definition: random:2357
template<class _Ty = int>
void uniform_int< _Ty >::reset ( )
inline
2275  { // clear internal state
2276  }

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: