<random>

public member function (公共成員函式)
<random>

std::shuffle_order_engine::operator()

result_type operator()();
生成隨機數
Returns a new random number. (返回一個新的隨機數。)

The engine's transition algorithm picks a value in the internal table (which is returned by the function) and replaces it with a new value obtained from its base engine. (引擎的轉換演算法選擇內部表中的一個值(由函式返回),並用從其基類引擎獲得的新值替換它。)

The generation algorithm simply returns the value picked. (生成演算法簡單地返回所選的值。)

引數



返回值

A new random number. (一個新的隨機數。)
result_type (結果型別)is a member type, defined as an alias of the type of the numbers generated by the base engine. (是一種成員型別,定義為由基類引擎生成的數字型別的別名。)

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// shuffle_order_engine::operator()
#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();

  // knuth_b is a standard shuffle_order_engine type:
  std::knuth_b generator (seed);
  std::cout << "Random value: " << generator() << std::endl;

  return 0;
}

可能的輸出
Random value: 304242968


複雜度

Determined by the base engine. (由基類引擎決定。)

另見