std::seed_seq::generate (3) - Linux Manuals
std::seed_seq::generate: std::seed_seq::generate
NAME
std::seed_seq::generate - std::seed_seq::generate
Synopsis
template< class RandomIt > (since C++11)
void generate( RandomIt begin, RandomIt end );
Fills the range [begin, end) with unsigned integer values i, 0 ≤ i < 232
, based on the data originally provided in the constructor of this seed_seq. The produced values are distributed over the entire 32-bit range even if the initial values were strongly biased.
The following algorithm is used (adapted from the initialization sequence of the Mersenne Twister generator by Makoto_Matsumoto_and_Takuji_Nishimura, incorporating the improvements made by Mutsuo_Saito_in_2007)
* If begin == end, do nothing. Otherwise,
* First, set each element of the output range to the value 0x8b8b8b8b
* Transform the elements of the output range according to the following algorithm:
For k = 0,..., m-1
where m=max(s+1, n)
and n=end-begin
and s=v.size()
and v is the private container holding the values originally provided by the constructor of this seed_seq object,
where p=(n-t)/2
and q=p+t
and t=(n >= 623) ? 11 : (n >= 68) ? 7 : (n >= 39) ? 5 : (n >= 7) ? 3 : (n - 1) / 2
and r1=1664525 * T(begin[k]^begin[k+p]^begin[k−1])
and T(x) = x ^ (x >> 27)
and r2=r1+s if k==0, r2=r1 + k%n + v[k-1] if 0<k<=s, r2=r1 + k%n if k>s.
For k = m,..., m+n-1,
where r3 = 1566083941 * T(begin[k]+begin[k+p]+begin[k-1])
and r4=r3 - k%n
where all calculations are performed modulo 232
and where the indexing of the output range (begin[x]) is taken modulo n.
Parameters
begin, end - mutable random-access iterators whose std::iterator_traits<>::value_type is an unsigned integer type suitable for storing 32-bit values
Type requirements
-
RandomIt must meet the requirements of LegacyRandomAccessIterator.
Return value
none, the results are written to the [begin, end) range.
Exceptions
Only throws if the operations on begin and end throw.
Example
// Run this code
Output: