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 input_type
 
typedef _Ty result_type
 

Public Member Functions

 uniform_int (_Ty _Min0=0, _Ty _Max0=9)
 
 uniform_int (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 >::input_type
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
2615  : _Par(_Min0, _Max0)
2616  { // construct from parameters
2617  }
param_type _Par
Definition: random:2737
template<class _Ty = int>
uniform_int< _Ty >::uniform_int ( param_type  _Par0)
inlineexplicit
2620  : _Par(_Par0)
2621  { // construct from parameter package
2622  }
param_type _Par
Definition: random:2737

Member Function Documentation

template<class _Ty = int>
static _Uty uniform_int< _Ty >::_Adjust ( _Uty  _Uval)
inlinestaticprivate
2718  { // convert signed ranges to unsigned ranges and vice versa
2719  return (_Adjust(_Uval, is_signed<_Ty>()));
2720  }
static _Uty _Adjust(_Uty _Uval)
Definition: random:2717
template<class _Ty = int>
static _Uty uniform_int< _Ty >::_Adjust ( _Uty  _Uval,
true_type   
)
inlinestaticprivate
2723  { // convert signed ranges to unsigned ranges and vice versa
2724  const _Uty _Adjuster = (_Uty(-1) >> 1) + 1; // 2^(N-1)
2725 
2726  if (_Uval < _Adjuster)
2727  return (_Uval + _Adjuster);
2728  else
2729  return (_Uval - _Adjuster);
2730  }
make_unsigned< _Ty >::type _Uty
Definition: random:2697
template<class _Ty = int>
static _Uty uniform_int< _Ty >::_Adjust ( _Uty  _Uval,
false_type   
)
inlinestaticprivate
2733  { // _Ty is already unsigned, do nothing
2734  return (_Uval);
2735  }
template<class _Ty = int>
template<class _Engine >
result_type uniform_int< _Ty >::_Eval ( _Engine &  _Eng,
_Ty  _Min,
_Ty  _Max 
) const
inlineprivate
2701  { // compute next value in range [_Min, _Max]
2702  _Rng_from_urng<_Uty, _Engine> _Rng(_Eng);
2703 
2704  const _Uty _Umin = _Adjust(_Uty(_Min));
2705  const _Uty _Umax = _Adjust(_Uty(_Max));
2706 
2707  _Uty _Uret = 0;
2708 
2709  if (_Umax - _Umin == _Uty(-1))
2710  _Uret = _Rng._Get_all_bits();
2711  else
2712  _Uret = _Rng(_Umax - _Umin + 1);
2713 
2714  return (_Ty(_Adjust(_Uret + _Umin)));
2715  }
Definition: xutility:3252
make_unsigned< _Ty >::type _Uty
Definition: random:2697
static _Uty _Adjust(_Uty _Uval)
Definition: random:2717
template<class _Ty = int>
template<class _Elem , class _Traits >
basic_istream<_Elem, _Traits>& uniform_int< _Ty >::_Read ( basic_istream< _Elem, _Traits > &  _Istr)
inline
2680  { // read state from _Istr
2681  _Ty _Min0;
2682  _Ty _Max0;
2683  _Istr >> _Min0 >> _Max0;
2684  _Par._Init(_Min0, _Max0);
2685  return (_Istr);
2686  }
void _Init(_Ty _Min0, _Ty _Max0)
Definition: random:2601
param_type _Par
Definition: random:2737
template<class _Ty = int>
template<class _Elem , class _Traits >
basic_ostream<_Elem, _Traits>& uniform_int< _Ty >::_Write ( basic_ostream< _Elem, _Traits > &  _Ostr) const
inline
2692  { // write state to _Ostr
2693  return (_Ostr << _Par._Min << ' ' << _Par._Max);
2694  }
param_type _Par
Definition: random:2737
result_type _Min
Definition: random:2609
result_type _Max
Definition: random:2610
template<class _Ty = int>
result_type uniform_int< _Ty >::a ( ) const
inline
2625  { // return a value
2626  return (_Par.a());
2627  }
param_type _Par
Definition: random:2737
result_type a() const
Definition: random:2591
template<class _Ty = int>
result_type uniform_int< _Ty >::b ( ) const
inline
2630  { // return b value
2631  return (_Par.b());
2632  }
param_type _Par
Definition: random:2737
result_type b() const
Definition: random:2596
template<class _Ty = int>
result_type() uniform_int< _Ty >::max ( ) const
inline
2650  { // return maximum possible generated value
2651  return (_Par._Max);
2652  }
param_type _Par
Definition: random:2737
result_type _Max
Definition: random:2610
template<class _Ty = int>
result_type() uniform_int< _Ty >::min ( ) const
inline
2645  { // return minimum possible generated value
2646  return (_Par._Min);
2647  }
param_type _Par
Definition: random:2737
result_type _Min
Definition: random:2609
template<class _Ty = int>
template<class _Engine >
result_type uniform_int< _Ty >::operator() ( _Engine &  _Eng) const
inline
2660  { // return next value
2661  return (_Eval(_Eng, _Par._Min, _Par._Max));
2662  }
param_type _Par
Definition: random:2737
result_type _Min
Definition: random:2609
result_type _Max
Definition: random:2610
result_type _Eval(_Engine &_Eng, _Ty _Min, _Ty _Max) const
Definition: random:2700
template<class _Ty = int>
template<class _Engine >
result_type uniform_int< _Ty >::operator() ( _Engine &  _Eng,
const param_type _Par0 
) const
inline
2666  { // return next value, given parameter package
2667  return (_Eval(_Eng, _Par0._Min, _Par0._Max));
2668  }
result_type _Eval(_Engine &_Eng, _Ty _Min, _Ty _Max) const
Definition: random:2700
template<class _Ty = int>
template<class _Engine >
result_type uniform_int< _Ty >::operator() ( _Engine &  _Eng,
result_type  _Nx 
) const
inline
2672  { // return next value
2673  return (_Eval(_Eng, 0, _Nx - 1));
2674  }
result_type _Eval(_Engine &_Eng, _Ty _Min, _Ty _Max) const
Definition: random:2700
template<class _Ty = int>
param_type uniform_int< _Ty >::param ( ) const
inline
2635  { // return parameter package
2636  return (_Par);
2637  }
param_type _Par
Definition: random:2737
template<class _Ty = int>
void uniform_int< _Ty >::param ( const param_type _Par0)
inline
2640  { // set parameter package
2641  _Par = _Par0;
2642  }
param_type _Par
Definition: random:2737
template<class _Ty = int>
void uniform_int< _Ty >::reset ( )
inline
2655  { // clear internal state
2656  }

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: