STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
_Swc_base< _Ty, _Sx, _Rx, _Swc_Traits > Class Template Reference
Inheritance diagram for _Swc_base< _Ty, _Sx, _Rx, _Swc_Traits >:
_Circ_buf< _Ty, _Rx >

Public Types

typedef _Ty result_type
 
typedef _Swc_Traits _Traits
 
typedef _Swc_base< _Ty, _Sx, _Rx, _Swc_Traits > _Myt
 
typedef _Circ_buf< _Ty, _Rx > _Mybase
 
typedef _Swc_Traits::_Seed_t _Seed_t
 

Public Member Functions

 _Swc_base ()
 
 _Swc_base (_Seed_t _X0)
 
template<class _Gen , class = typename _Enable_if_seed_seq<_Gen, _Myt>::type>
 _Swc_base (_Gen &_Gx)
 
void seed (_Seed_t _Value=default_seed)
 
template<class _Gen >
void seed (_Gen &_Gx, bool _Readcy=false)
 
result_type() min () const
 
result_type() max () const
 
result_type operator() ()
 
void discard (unsigned long long _Nskip)
 
bool _Equals (const _Swc_base &_Right) const
 
template<class _Elem , class _Traits >
basic_ostream< _Elem, _Traits > & _Write (basic_ostream< _Elem, _Traits > &_Ostr) const
 
- Public Member Functions inherited from _Circ_buf< _Ty, _Rx >
_Ty _At (int _Ix) const
 
bool _Equals (const _Circ_buf &_Right) const
 
unsigned int _Base (int _Ix=0) const
 

Static Public Attributes

static constexpr size_t short_lag = _Sx
 
static constexpr size_t long_lag = _Rx
 
static constexpr _Seed_t default_seed = static_cast<_Seed_t>(19780503U)
 

Protected Member Functions

template<class _Gen >
void _Seed (_Gen &_Gx, bool _Readcy, true_type)
 
template<class _Gen >
void _Seed (_Gen &_Gx, bool _Readcy, false_type)
 
template<class _Gen >
void _Reset (_Gen &_Gx, bool _Readcy)
 
void _Setx (int _Ix, _Ty _Xis, _Ty _Xir)
 

Protected Attributes

_Swc_Traits::_Cy_t _Carry
 

Additional Inherited Members

- Public Attributes inherited from _Circ_buf< _Ty, _Rx >
unsigned int _Idx
 
_Ty _Ax [2 *_Nw]
 

Member Typedef Documentation

template<class _Ty, size_t _Sx, size_t _Rx, class _Swc_Traits>
typedef _Circ_buf<_Ty, _Rx> _Swc_base< _Ty, _Sx, _Rx, _Swc_Traits >::_Mybase
template<class _Ty, size_t _Sx, size_t _Rx, class _Swc_Traits>
typedef _Swc_base<_Ty, _Sx, _Rx, _Swc_Traits> _Swc_base< _Ty, _Sx, _Rx, _Swc_Traits >::_Myt
template<class _Ty, size_t _Sx, size_t _Rx, class _Swc_Traits>
typedef _Swc_Traits::_Seed_t _Swc_base< _Ty, _Sx, _Rx, _Swc_Traits >::_Seed_t
template<class _Ty, size_t _Sx, size_t _Rx, class _Swc_Traits>
typedef _Swc_Traits _Swc_base< _Ty, _Sx, _Rx, _Swc_Traits >::_Traits
template<class _Ty, size_t _Sx, size_t _Rx, class _Swc_Traits>
typedef _Ty _Swc_base< _Ty, _Sx, _Rx, _Swc_Traits >::result_type

Constructor & Destructor Documentation

template<class _Ty, size_t _Sx, size_t _Rx, class _Swc_Traits>
_Swc_base< _Ty, _Sx, _Rx, _Swc_Traits >::_Swc_base ( )
inline
755  { // construct with default seed
756  seed();
757  }
void seed(_Seed_t _Value=default_seed)
Definition: random:771
template<class _Ty, size_t _Sx, size_t _Rx, class _Swc_Traits>
_Swc_base< _Ty, _Sx, _Rx, _Swc_Traits >::_Swc_base ( _Seed_t  _X0)
inline
760  { // construct with specified seed
761  seed(_X0);
762  }
void seed(_Seed_t _Value=default_seed)
Definition: random:771
template<class _Ty, size_t _Sx, size_t _Rx, class _Swc_Traits>
template<class _Gen , class = typename _Enable_if_seed_seq<_Gen, _Myt>::type>
_Swc_base< _Ty, _Sx, _Rx, _Swc_Traits >::_Swc_base ( _Gen &  _Gx)
inline
767  { // construct with seed values from generator
768  seed(_Gx);
769  }
void seed(_Seed_t _Value=default_seed)
Definition: random:771

Member Function Documentation

template<class _Ty, size_t _Sx, size_t _Rx, class _Swc_Traits>
bool _Swc_base< _Ty, _Sx, _Rx, _Swc_Traits >::_Equals ( const _Swc_base< _Ty, _Sx, _Rx, _Swc_Traits > &  _Right) const
inline
813  { // return true if *this will generate same sequence as _Right
814  return (_Mybase::_Equals(_Right)
815  && _Carry == _Right._Carry);
816  }
bool _Equals(const _Circ_buf &_Right) const
Definition: random:682
_Swc_Traits::_Cy_t _Carry
Definition: random:869
template<class _Ty, size_t _Sx, size_t _Rx, class _Swc_Traits>
template<class _Gen >
void _Swc_base< _Ty, _Sx, _Rx, _Swc_Traits >::_Reset ( _Gen &  _Gx,
bool  _Readcy 
)
inlineprotected
844  { // reset sequence
845  _Carry = _Swc_Traits::_Reset(_Gx, this->_Ax, _Readcy);
846  this->_Idx = _Rx;
847  }
unsigned int _Idx
Definition: random:731
_Ty _Ax[2 *_Nw]
Definition: random:732
_Swc_Traits::_Cy_t _Carry
Definition: random:869
template<class _Ty, size_t _Sx, size_t _Rx, class _Swc_Traits>
template<class _Gen >
void _Swc_base< _Ty, _Sx, _Rx, _Swc_Traits >::_Seed ( _Gen &  _Gx,
bool  _Readcy,
true_type   
)
inlineprotected
830  { // reset sequence from numeric value
832  _Gx == 0U ? default_seed : _Gx);
833  _Reset(_Lc, _Readcy);
834  }
Definition: random:465
void _Reset(_Gen &_Gx, bool _Readcy)
Definition: random:843
static constexpr _Seed_t default_seed
Definition: random:752
template<class _Ty, size_t _Sx, size_t _Rx, class _Swc_Traits>
template<class _Gen >
void _Swc_base< _Ty, _Sx, _Rx, _Swc_Traits >::_Seed ( _Gen &  _Gx,
bool  _Readcy,
false_type   
)
inlineprotected
838  { // reset sequence from generator
839  _Reset(_Gx, _Readcy);
840  }
void _Reset(_Gen &_Gx, bool _Readcy)
Definition: random:843
template<class _Ty, size_t _Sx, size_t _Rx, class _Swc_Traits>
void _Swc_base< _Ty, _Sx, _Rx, _Swc_Traits >::_Setx ( int  _Ix,
_Ty  _Xis,
_Ty  _Xir 
)
inlineprotected
850  { // update _Ax[_Ix] and _Carry
851  bool _Underflowed = false;
852  _Ty _Newx = _Xis;
853  if (_Newx < _Xir)
854  _Underflowed = true;
855  _Newx -= _Xir;
856  if (_Newx < static_cast<typename _Swc_Traits::_UCy_t>(_Carry))
857  _Underflowed = true;
858  _Newx -= _Carry;
859  if (_Underflowed)
860  { // underflowed, so add _Mod
861  _Newx += _Swc_Traits::_Mod;
862  _Carry = _Swc_Traits::_Cy;
863  }
864  else
865  _Carry = 0;
866  this->_Ax[_Ix] = _Newx;
867  }
_Ty _Ax[2 *_Nw]
Definition: random:732
_Swc_Traits::_Cy_t _Carry
Definition: random:869
template<class _Ty, size_t _Sx, size_t _Rx, class _Swc_Traits>
template<class _Elem , class _Traits >
basic_ostream<_Elem, _Traits>& _Swc_base< _Ty, _Sx, _Rx, _Swc_Traits >::_Write ( basic_ostream< _Elem, _Traits > &  _Ostr) const
inline
822  { // write state to _Ostr
823  _Swc_Traits::_Write(_Ostr, *this, _Carry);
824  return (_Ostr);
825  }
_Swc_Traits::_Cy_t _Carry
Definition: random:869
basic_ostream< _Elem, _Traits > & _Write(basic_ostream< _Elem, _Traits > &_Os, long double _Dx)
Definition: random:93
template<class _Ty, size_t _Sx, size_t _Rx, class _Swc_Traits>
void _Swc_base< _Ty, _Sx, _Rx, _Swc_Traits >::discard ( unsigned long long  _Nskip)
inline
807  { // discard _Nskip elements
808  for (; 0 < _Nskip; --_Nskip)
809  (*this)();
810  }
template<class _Ty, size_t _Sx, size_t _Rx, class _Swc_Traits>
result_type() _Swc_base< _Ty, _Sx, _Rx, _Swc_Traits >::max ( ) const
inline
788  { // return maximum possible generated value
789  return (_Swc_Traits::_Max);
790  }
template<class _Ty, size_t _Sx, size_t _Rx, class _Swc_Traits>
result_type() _Swc_base< _Ty, _Sx, _Rx, _Swc_Traits >::min ( ) const
inline
783  { // return minimum possible generated value
784  return (0);
785  }
template<class _Ty, size_t _Sx, size_t _Rx, class _Swc_Traits>
result_type _Swc_base< _Ty, _Sx, _Rx, _Swc_Traits >::operator() ( )
inline
793  { // return next value
794  int _Ix = 2 * _Rx <= this->_Idx ? 0 : this->_Idx;
795  if (_Ix < _Sx)
796  _Setx(_Ix, this->_Ax[_Ix + 2 * _Rx - _Sx],
797  this->_Ax[_Ix + _Rx]);
798  else if (_Ix < _Rx)
799  _Setx(_Ix, this->_Ax[_Ix - _Sx], this->_Ax[_Ix + _Rx]);
800  else
801  _Setx(_Ix, this->_Ax[_Ix - _Sx], this->_Ax[_Ix - _Rx]);
802  this->_Idx = _Ix + 1;
803  return (this->_Ax[_Ix]);
804  }
unsigned int _Idx
Definition: random:731
_Ty _Ax[2 *_Nw]
Definition: random:732
void _Setx(int _Ix, _Ty _Xis, _Ty _Xir)
Definition: random:849
template<class _Ty, size_t _Sx, size_t _Rx, class _Swc_Traits>
void _Swc_base< _Ty, _Sx, _Rx, _Swc_Traits >::seed ( _Seed_t  _Value = default_seed)
inline
772  { // set initial values from specified seed value
773  _Seed(_Value, false, true_type());
774  }
void _Seed(_Gen &_Gx, bool _Readcy, true_type)
Definition: random:829
integral_constant< bool, true > true_type
Definition: xtr1common:40
_In_ int _Value
Definition: setjmp.h:173
template<class _Ty, size_t _Sx, size_t _Rx, class _Swc_Traits>
template<class _Gen >
void _Swc_base< _Ty, _Sx, _Rx, _Swc_Traits >::seed ( _Gen &  _Gx,
bool  _Readcy = false 
)
inline
778  { // set initial values from range
779  _Seed(_Gx, _Readcy, is_arithmetic<_Gen>());
780  }
Definition: xtr1common:287
void _Seed(_Gen &_Gx, bool _Readcy, true_type)
Definition: random:829

Member Data Documentation

template<class _Ty, size_t _Sx, size_t _Rx, class _Swc_Traits>
_Swc_Traits::_Cy_t _Swc_base< _Ty, _Sx, _Rx, _Swc_Traits >::_Carry
protected
template<class _Ty, size_t _Sx, size_t _Rx, class _Swc_Traits>
constexpr _Seed_t _Swc_base< _Ty, _Sx, _Rx, _Swc_Traits >::default_seed = static_cast<_Seed_t>(19780503U)
static
template<class _Ty, size_t _Sx, size_t _Rx, class _Swc_Traits>
const size_t _Swc_base< _Ty, _Sx, _Rx, _Swc_Traits >::long_lag = _Rx
static
template<class _Ty, size_t _Sx, size_t _Rx, class _Swc_Traits>
const size_t _Swc_base< _Ty, _Sx, _Rx, _Swc_Traits >::short_lag = _Sx
static

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