<random>

public member function (公共成员函数)
<random>

std::shuffle_order_engine::seed (std::shuffle_order_engine::seed)

(1)
void seed();
(2)
void seed (result_type val);
(3)
template <class Sseq>void seed (Sseq& q);
Seed base engine (为基础引擎设置种子)
Re-initializes the state of the base engine, by calling its (通过调用 基础 引擎的)seed (种子)member function with the same argument (if any). (同名参数(如果存在)成员函数,重新初始化其状态。)

参数

val (val)
A seeding value. This value is passed to the base engine's constructor. (一个种子值。此值会被传递给 基础 引擎的构造函数。)
result_type (结果类型)is a member type, defined as an alias of the type of elements produced by base. (是一个成员类型,定义为 基础 引擎产生的元素类型的别名。)
q (q)
一个种子序列对象,例如seed_seq类型的对象。
Sseq (Sseq)应为具有generate成员函数的种子序列类。

返回值



示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// shuffle_order_engine::seed example
#include <iostream>
#include <chrono>
#include <random>

int main ()
{
  typedef std::chrono::high_resolution_clock myclock;
  myclock::time_point beginning = myclock::now();

  // obtain a seed from a user string:
  std::string str;
  std::cout << "Please, enter a seed: ";
  std::getline(std::cin,str);
  std::seed_seq seed1 (str.begin(),str.end());

  // obtain a seed from the timer
  myclock::duration d = myclock::now() - beginning;
  unsigned seed2 = d.count();

  // knuth_b is a standard shuffle_order_engine type:
  std::knuth_b generator (seed1);
  std::cout << "Your seed produced: " << generator() << std::endl;

  generator.seed (seed2);
  std::cout << "A time seed produced: " << generator() << std::endl;

  return 0;
}

可能的输出
Please, enter a seed: Knuth
Your seed produced: 361757427
A time seed produced: 1437485371


复杂度

Determined by the base engine. (由 基础 引擎决定。)

另见