STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
seed_seq Class Reference

Public Types

typedef unsigned int result_type
 

Public Member Functions

 seed_seq ()
 
template<class _Ty >
 seed_seq (_XSTD initializer_list< _Ty > _Ilist)
 
template<class _InIt >
 seed_seq (_InIt _First, _InIt _Last)
 
template<class _RanIt >
void generate (_RanIt _First, _RanIt _Last) const
 
template<class _OutIt >
void param (_OutIt _Dest) const
 
size_t size () const _NOEXCEPT
 
 seed_seq (const seed_seq &)=delete
 
void operator= (const seed_seq &)=delete
 

Private Member Functions

template<class _InIt >
void _Construct (_InIt _First, _InIt _Last)
 
template<class _RanIt >
void _Generate_unchecked (_RanIt _First, _RanIt _Last) const
 
result_type _Xor27 (result_type _Val) const
 

Private Attributes

vector< result_type_Myvec
 

Member Typedef Documentation

typedef unsigned int seed_seq::result_type

Constructor & Destructor Documentation

seed_seq::seed_seq ( )
inline
189  { // default constructor
190  }
template<class _Ty >
seed_seq::seed_seq ( _XSTD initializer_list< _Ty >  _Ilist)
inline
194  { // construct from [_First, _Last)
195  _Construct(_Ilist.begin(), _Ilist.end());
196  }
void _Construct(_InIt _First, _InIt _Last)
Definition: random:227
template<class _InIt >
seed_seq::seed_seq ( _InIt  _First,
_InIt  _Last 
)
inline
200  { // construct from [_First, _Last)
201  _Construct(_First, _Last);
202  }
void _Construct(_InIt _First, _InIt _Last)
Definition: random:227
_FwdIt _Last
Definition: algorithm:1936
seed_seq::seed_seq ( const seed_seq )
delete

Member Function Documentation

template<class _InIt >
void seed_seq::_Construct ( _InIt  _First,
_InIt  _Last 
)
inlineprivate
228  { // construct from [_First, _Last)
229  for (; _First != _Last; ++_First)
230  _Myvec.push_back((unsigned int)*_First);
231  }
void push_back(value_type &&_Val)
Definition: vector:895
vector< result_type > _Myvec
Definition: random:288
_FwdIt _Last
Definition: algorithm:1936
template<class _RanIt >
void seed_seq::_Generate_unchecked ( _RanIt  _First,
_RanIt  _Last 
) const
inlineprivate
235  { // generate randomized interval from seeds
236  const size_t _Nx = _Last - _First;
237 
238  if (0 < _Nx)
239  { // finite interval, fill it
240  const size_t _Sx = _Myvec.size();
241  const size_t _Tx = 623 <= _Nx ? 11 : 68 <= _Nx ? 7
242  : 39 <= _Nx ? 5 : 7 <= _Nx ? 3 : (_Nx - 1) / 2;
243  const size_t _Px = (_Nx - _Tx) / 2;
244  const size_t _Qx = _Px + _Tx;
245  const size_t _Mx = _Nx <= _Sx ? _Sx + 1 : _Nx;
246  size_t _Kx;
247 
249  _Mask <<= 1; // build 32-bit mask safely
250  _Mask -= 1;
251 
252  for (_Kx = 0; _Kx < _Nx; ++_Kx)
253  _First[_Kx] = 0x8b8b8b8b;
254  for (_Kx = 0; _Kx < _Mx; ++_Kx)
255  { // scramble and add any vector contributions
256  result_type _R1 = 1664525 * _Xor27(_First[_Kx % _Nx]
257  ^ _First[(_Kx + _Px) % _Nx] ^ _First[(_Kx - 1) % _Nx]);
258  result_type _R2 = (result_type)((_R1 + (_Kx == 0 ? _Sx
259  : _Kx <= _Sx ? _Kx % _Nx + _Myvec[(_Kx - 1) % _Sx]
260  : _Kx % _Nx)) & _Mask);
261 
262  _First[(_Kx + _Px) % _Nx] =
263  (_First[(_Kx + _Px) % _Nx] + _R1) & _Mask;
264  _First[(_Kx + _Qx) % _Nx] =
265  (_First[(_Kx + _Qx) % _Nx] + _R2) & _Mask;
266  _First[_Kx % _Nx] = _R2;
267  }
268  for (; _Kx < _Mx + _Nx; ++_Kx)
269  { // rescramble
270  result_type _R3 = 1566083941 * _Xor27(_First[_Kx % _Nx]
271  + _First[(_Kx + _Px) % _Nx] + _First[(_Kx - 1) % _Nx]);
272  result_type _R4 = (result_type)((_R3 - _Kx % _Nx) & _Mask);
273 
274  _First[(_Kx + _Px) % _Nx] =
275  (_First[(_Kx + _Px) % _Nx] ^ _R3) & _Mask;
276  _First[(_Kx + _Qx) % _Nx] =
277  (_First[(_Kx + _Qx) % _Nx] ^ _R4) & _Mask;
278  _First[_Kx % _Nx] = _R4;
279  }
280  }
281  }
result_type _Xor27(result_type _Val) const
Definition: random:283
size_type size() const _NOEXCEPT
Definition: vector:1178
unsigned int result_type
Definition: random:186
typename iterator_traits< _Iter >::value_type _Iter_value_t
Definition: xutility:647
vector< result_type > _Myvec
Definition: random:288
_FwdIt _Last
Definition: algorithm:1936
result_type seed_seq::_Xor27 ( result_type  _Val) const
inlineprivate
284  { // shift and merge
285  return (_Val ^ (_Val >> 27));
286  }
_In_ int _Val
Definition: vcruntime_string.h:62
template<class _RanIt >
void seed_seq::generate ( _RanIt  _First,
_RanIt  _Last 
) const
inline
206  { // generate randomized interval from seeds
207  _DEBUG_RANGE(_First, _Last);
209  }
#define _DEBUG_RANGE(first, last)
Definition: xutility:822
_Iter_t _Unchecked(_Iter_t _Iter)
Definition: iterator:11
void _Generate_unchecked(_RanIt _First, _RanIt _Last) const
Definition: random:234
_FwdIt _Last
Definition: algorithm:1936
void seed_seq::operator= ( const seed_seq )
delete
template<class _OutIt >
void seed_seq::param ( _OutIt  _Dest) const
inline
213  { // copy seeds
214  _STD copy(_Myvec.begin(), _Myvec.end(), _Dest);
215  }
_OutIt copy(_InIt _First, _InIt _Last, _OutIt _Dest)
Definition: xutility:2369
iterator begin() _NOEXCEPT
Definition: vector:1056
iterator end() _NOEXCEPT
Definition: vector:1066
vector< result_type > _Myvec
Definition: random:288
size_t seed_seq::size ( ) const
inline
218  { // get size of seed
219  return (_Myvec.size());
220  }
size_type size() const _NOEXCEPT
Definition: vector:1178
vector< result_type > _Myvec
Definition: random:288

Member Data Documentation

vector<result_type> seed_seq::_Myvec
private

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