公有成员函数
<random>

std::discard_block_engine::discard

void discard (unsigned long long z);
Advance internal state (推进内部状态)
将内部状态推进z个刻度,如同调用zoperator() 一样,但不会生成任何数字。

对状态序列的影响与在后续元素上应用转换算法的次数相同。

参数

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
// discard_block_engine::discard
#include <iostream>
#include <chrono>
#include <random>

int main ()
{
  // obtain a seed from the system clock:
  unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();

  // ranlux24 is a standard instantitation of discard_block_engine:
  std::ranlux24 generator (seed);

  std::cout << "Random value: " << generator() << std::endl;

  generator.discard(generator.used_block);  // advance an entire block

  std::cout << "Random value: " << generator() << std::endl;

  return 0;
}

可能的输出
Random value: 6747515
Random value: 8481690


复杂度

Linear in z. (与z呈线性关系。)

另见