public member function (公共成員函式)
<random>
void discard (unsigned long long z);
Advance internal state (推進內部狀態)
Advances the internal state by z notches, as if operator() was called z times, but without generating any numbers in the process. (將內部狀態推進z個刻度,就像呼叫了operator() z次一樣,但在此過程中不生成任何數字。)
The effects on the state sequence are the same as if the transition algorithm was applied z times on subsequent elements. (對狀態序列的影響與轉移演算法對後續元素應用z次的效果相同。)
引數
- z
- Number of equivalent advances. (等效推進的次數。)
示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
// independent_bits_engine::discard
#include <iostream>
#include <chrono>
#include <cstdint>
#include <random>
int main ()
{
// obtain a seed from the system clock:
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::independent_bits_engine<std::mt19937,64,std::uint_fast64_t> generator (seed);
std::cout << "Random value: " << generator() << std::endl;
generator.discard(1); // discard one element
std::cout << "Random value: " << generator() << std::endl;
return 0;
}
|
可能的輸出
Random value: 13760645581718272663
Random value: 451864462774584642
|
複雜度
Linear in z. (與z呈線性關係。)