STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
independent_bits_engine< _Engine, _Wx, _UIntType > Class Template Reference

Public Types

typedef independent_bits_engine< _Engine, _Wx, _UIntType > _Myt
 
typedef _Engine base_type
 
typedef _UIntType result_type
 
typedef _Engine::result_type _Eres
 

Public Member Functions

 independent_bits_engine ()
 
 independent_bits_engine (const _Engine &_Ex)
 
 independent_bits_engine (_Engine &&_Ex)
 
 independent_bits_engine (result_type _X0)
 
template<class _Seed_seq , class = typename _Enable_if_seed_seq<_Seed_seq, _Myt, _Engine>::type>
 independent_bits_engine (_Seed_seq &_Seq)
 
void seed ()
 
void seed (result_type _X0)
 
template<class _Seed_seq , class = typename _Enable_if_seed_seq<_Seed_seq, _Myt>::type>
void seed (_Seed_seq &_Seq)
 
const _Engine & base () const _NOEXCEPT
 
result_type operator() ()
 
void discard (unsigned long long _Nskip)
 
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
 

Static Public Member Functions

static constexpr result_type() min ()
 
static constexpr result_type() max ()
 

Private Member Functions

void _Init ()
 

Private Attributes

_Engine _Eng
 
size_t _N0
 
size_t _Nx
 
size_t _W0
 
_Eres _Y0
 
_Eres _Y1
 

Member Typedef Documentation

template<class _Engine, size_t _Wx, class _UIntType>
typedef _Engine::result_type independent_bits_engine< _Engine, _Wx, _UIntType >::_Eres
template<class _Engine, size_t _Wx, class _UIntType>
typedef independent_bits_engine<_Engine, _Wx, _UIntType> independent_bits_engine< _Engine, _Wx, _UIntType >::_Myt
template<class _Engine, size_t _Wx, class _UIntType>
typedef _Engine independent_bits_engine< _Engine, _Wx, _UIntType >::base_type
template<class _Engine, size_t _Wx, class _UIntType>
typedef _UIntType independent_bits_engine< _Engine, _Wx, _UIntType >::result_type

Constructor & Destructor Documentation

template<class _Engine, size_t _Wx, class _UIntType>
independent_bits_engine< _Engine, _Wx, _UIntType >::independent_bits_engine ( )
inline
1813  { // construct
1814  _Init();
1815  }
void _Init()
Definition: random:1930
template<class _Engine, size_t _Wx, class _UIntType>
independent_bits_engine< _Engine, _Wx, _UIntType >::independent_bits_engine ( const _Engine &  _Ex)
inlineexplicit
1818  : _Eng(_Ex)
1819  { // construct with engine initializer _Ex
1820  _Init();
1821  }
_Engine _Eng
Definition: random:1958
void _Init()
Definition: random:1930
template<class _Engine, size_t _Wx, class _UIntType>
independent_bits_engine< _Engine, _Wx, _UIntType >::independent_bits_engine ( _Engine &&  _Ex)
inlineexplicit
1824  : _Eng(_STD forward<_Engine>(_Ex))
1825  { // construct with engine initializer _Ex
1826  _Init();
1827  }
_Engine _Eng
Definition: random:1958
void _Init()
Definition: random:1930
template<class _Engine, size_t _Wx, class _UIntType>
independent_bits_engine< _Engine, _Wx, _UIntType >::independent_bits_engine ( result_type  _X0)
inlineexplicit
1830  : _Eng(_X0)
1831  { // construct from specified seed value
1832  _Init();
1833  }
_Engine _Eng
Definition: random:1958
void _Init()
Definition: random:1930
template<class _Engine, size_t _Wx, class _UIntType>
template<class _Seed_seq , class = typename _Enable_if_seed_seq<_Seed_seq, _Myt, _Engine>::type>
independent_bits_engine< _Engine, _Wx, _UIntType >::independent_bits_engine ( _Seed_seq &  _Seq)
inlineexplicit
1838  : _Eng(_Seq)
1839  { // construct from seed sequence
1840  _Init();
1841  }
_Engine _Eng
Definition: random:1958
void _Init()
Definition: random:1930

Member Function Documentation

template<class _Engine, size_t _Wx, class _UIntType>
void independent_bits_engine< _Engine, _Wx, _UIntType >::_Init ( )
inlineprivate
1931  { // compute values for operator()
1932  size_t _Mx = 0;
1933  _Eres _Rx = (_Engine::max)() - (_Engine::min)() + 1;
1934 
1935  _Eres _Tmp = _Rx;
1936  if (_Tmp == 0)
1937  { // all bits used, make _Rx finite
1938  _Mx = 1;
1939  --_Tmp;
1940  }
1941  for (; 1 < _Tmp; _Tmp >>= 1)
1942  ++_Mx; // compute _Mx = floor(log2(_Rx))
1943 
1944  for (size_t _Nfix = 0; ; ++_Nfix)
1945  { // compute consistent set of parameters
1946  _Nx = (_Wx + _Mx - 1) / _Mx + _Nfix; // trial _Nx
1947  _W0 = _Wx / _Nx;
1948  _N0 = _Nx - _Wx % _Nx;
1949  _Y0 = (_Rx >> _W0) << _W0;
1950  _Y1 = (((_Rx >> _W0) >> 1) << _W0) << 1;
1951  if (_Nfix == 1 || _Rx - _Y0 <= _Y0 / _Nx)
1952  break; // also works if _Rx == 0 (_Mx == all bits)
1953  }
1954  --_Y0;
1955  --_Y1;
1956  }
_Engine::result_type _Eres
Definition: random:1810
_Eres _Y1
Definition: random:1963
constexpr const _Ty &() max(const _Ty &_Left, const _Ty &_Right, _Pr _Pred) _NOEXCEPT_OP(_NOEXCEPT_OP(_DEBUG_LT_PRED(_Pred
size_t _Nx
Definition: random:1960
_Eres _Y0
Definition: random:1962
size_t _W0
Definition: random:1961
size_t _N0
Definition: random:1959
constexpr const _Ty &() min(const _Ty &_Left, const _Ty &_Right, _Pr _Pred) _NOEXCEPT_OP(_NOEXCEPT_OP(_DEBUG_LT_PRED(_Pred
template<class _Engine, size_t _Wx, class _UIntType>
template<class _Elem , class _Traits >
basic_istream<_Elem, _Traits>& independent_bits_engine< _Engine, _Wx, _UIntType >::_Read ( basic_istream< _Elem, _Traits > &  _Istr)
inline
1917  { // read state from _Istr
1918  return (_Istr >> _Eng);
1919  }
_Engine _Eng
Definition: random:1958
template<class _Engine, size_t _Wx, class _UIntType>
template<class _Elem , class _Traits >
basic_ostream<_Elem, _Traits>& independent_bits_engine< _Engine, _Wx, _UIntType >::_Write ( basic_ostream< _Elem, _Traits > &  _Ostr) const
inline
1925  { // write state to _Ostr
1926  return (_Ostr << _Eng);
1927  }
_Engine _Eng
Definition: random:1958
template<class _Engine, size_t _Wx, class _UIntType>
const _Engine& independent_bits_engine< _Engine, _Wx, _UIntType >::base ( ) const
inline
1861  { // return const reference to engine
1862  return (_Eng);
1863  }
_Engine _Eng
Definition: random:1958
template<class _Engine, size_t _Wx, class _UIntType>
void independent_bits_engine< _Engine, _Wx, _UIntType >::discard ( unsigned long long  _Nskip)
inline
1908  { // discard _Nskip elements
1909  for (; 0 < _Nskip; --_Nskip)
1910  (*this)();
1911  }
template<class _Engine, size_t _Wx, class _UIntType>
static constexpr result_type() independent_bits_engine< _Engine, _Wx, _UIntType >::max ( )
inlinestatic
1871  { // return maximum possible generated value
1872  return ((((result_type)1 << (_Wx - 1)) << 1) - 1);
1873  }
_UIntType result_type
Definition: random:1809
template<class _Engine, size_t _Wx, class _UIntType>
static constexpr result_type() independent_bits_engine< _Engine, _Wx, _UIntType >::min ( )
inlinestatic
1866  { // return minimum possible generated value
1867  return (0);
1868  }
template<class _Engine, size_t _Wx, class _UIntType>
result_type independent_bits_engine< _Engine, _Wx, _UIntType >::operator() ( )
inline
1876  { // return next value
1877  size_t _Idx = 0;
1878  result_type _Res = 0;
1879  result_type _Mask = (((result_type)1 << (_W0 - 1)) << 1) - 1;
1880  _Eres _Val;
1881 
1882  for (; _Idx < _N0; ++_Idx)
1883  { // pack _W0-bit values
1884  for (; ; )
1885  { // get a small enough value
1886  _Val = _Eng() - (_Engine::min)();
1887  if (_Val <= _Y0)
1888  break;
1889  }
1890  _Res = _Res << _W0 | static_cast<result_type>(_Val) & _Mask;
1891  }
1892 
1893  _Mask = _Mask << 1 | 1;
1894  for (; _Idx < _Nx; ++_Idx)
1895  { // pack _W0+1-bit values
1896  for (; ; )
1897  { // get a small enough value
1898  _Val = _Eng() - (_Engine::min)();
1899  if (_Val <= _Y1)
1900  break;
1901  }
1902  _Res = (_Res << (_W0 + 1)) | static_cast<result_type>(_Val) & _Mask;
1903  }
1904  return (_Res);
1905  }
_Engine::result_type _Eres
Definition: random:1810
_In_ int _Val
Definition: vcruntime_string.h:62
_Eres _Y1
Definition: random:1963
_Engine _Eng
Definition: random:1958
_UIntType result_type
Definition: random:1809
size_t _Nx
Definition: random:1960
_Eres _Y0
Definition: random:1962
size_t _W0
Definition: random:1961
size_t _N0
Definition: random:1959
constexpr const _Ty &() min(const _Ty &_Left, const _Ty &_Right, _Pr _Pred) _NOEXCEPT_OP(_NOEXCEPT_OP(_DEBUG_LT_PRED(_Pred
template<class _Engine, size_t _Wx, class _UIntType>
void independent_bits_engine< _Engine, _Wx, _UIntType >::seed ( )
inline
1844  { // seed engine from default value
1845  _Eng.seed();
1846  }
_Engine _Eng
Definition: random:1958
template<class _Engine, size_t _Wx, class _UIntType>
void independent_bits_engine< _Engine, _Wx, _UIntType >::seed ( result_type  _X0)
inline
1849  { // seed engine from specified value
1850  _Eng.seed(_X0);
1851  }
_Engine _Eng
Definition: random:1958
template<class _Engine, size_t _Wx, class _UIntType>
template<class _Seed_seq , class = typename _Enable_if_seed_seq<_Seed_seq, _Myt>::type>
void independent_bits_engine< _Engine, _Wx, _UIntType >::seed ( _Seed_seq &  _Seq)
inline
1856  { // seed engine from seed sequence
1857  _Eng.seed(_Seq);
1858  }
_Engine _Eng
Definition: random:1958

Member Data Documentation

template<class _Engine, size_t _Wx, class _UIntType>
_Engine independent_bits_engine< _Engine, _Wx, _UIntType >::_Eng
private
template<class _Engine, size_t _Wx, class _UIntType>
size_t independent_bits_engine< _Engine, _Wx, _UIntType >::_N0
private
template<class _Engine, size_t _Wx, class _UIntType>
size_t independent_bits_engine< _Engine, _Wx, _UIntType >::_Nx
private
template<class _Engine, size_t _Wx, class _UIntType>
size_t independent_bits_engine< _Engine, _Wx, _UIntType >::_W0
private
template<class _Engine, size_t _Wx, class _UIntType>
_Eres independent_bits_engine< _Engine, _Wx, _UIntType >::_Y0
private
template<class _Engine, size_t _Wx, class _UIntType>
_Eres independent_bits_engine< _Engine, _Wx, _UIntType >::_Y1
private

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