首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::seed_seq

Defined in header <random>

?

?

class seed_seq;

?

(since C++11)

std::seed_seq使用整数值数据序列,并生成所请求的无符号整数值数。i,0≤i<232

,基于消耗的数据。所产生的值分布在整个32位范围内,即使消耗的值接近。

它提供了一种方法来为大量的随机数引擎播种种子,或者在给定一个小种子或一个分布不佳的初始种子序列的情况下,为需要大量熵的生成器播种。

std::seed_seq满足…的要求SeedSequence...

成员类型

Member type

Definition

result_type

std::uint_least32_t

成员函数

(constructor)

constructs and seeds the std::seed_seq object (public member function)

operator= (deleted)

not copy-assignable (public member function)

generate

calculates the bias-eliminated, evenly distributed 32-bit values (public member function)

size

obtains the number of 32-bit values stored in std::seed_seq (public member function)

param

obtains the 32-bit values stored in std::seed_seq (public member function)

二次

代码语言:javascript
复制
#include <random>
#include <cstdint>
#include <iostream>
 
int main()
{
    std::seed_seq seq{1,2,3,4,5};
    std::vector<std::uint32_t> seeds(10);
    seq.generate(seeds.begin(), seeds.end());
    for (std::uint32_t n : seeds) {
        std::cout << n << '\n';
    }
}

二次

产出:

二次

代码语言:javascript
复制
4204997637
4246533866
1856049002
1129615051
690460811
1075771511
46783058
3904109078
1534123438
1495905678

二次

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com