NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
random_lcd类 参考

线性同余随机数生成器 更多...

#include <random.hpp>

Public 类型

using seed_type = uint32_t
 种子类型

Public 成员函数

 random_lcd () noexcept
 默认构造函数 默认使用当前时间戳值作为种子。
 random_lcd (const seed_type seed) noexcept
 带种子构造函数
template<typename T>
next_int (T max) noexcept
 生成 [0, max) 范围内的随机整数
template<typename T>
next_int (T min, T max) noexcept
 生成 [min, max) 范围内的随机整数
template<typename T>
next_int () noexcept
 生成完整范围的随机整数
uint64_t next_uint64 (uint64_t max) noexcept
 生成 [0, max) 范围内的随机 64 位整数
uint64_t next_uint64 () noexcept
 生成完整范围的随机 64 位整数
template<typename T>
next_float () noexcept
 生成 [0, 1) 范围内的随机浮点数
template<typename T>
next_float (T min, T max) noexcept
 生成 [min, max) 范围内的随机浮点数
template<typename T>
next_float (T max) noexcept
 生成 [0, max) 范围内的随机浮点数

详细描述

线性同余随机数生成器

使用线性同余算法 LCD 生成伪随机数,速度快但随机性一般。

在文件 random.hpp58 行定义.

构造及析构函数说明

◆ random_lcd()

random_lcd::random_lcd ( const seed_type seed)
inlineexplicitnoexcept

带种子构造函数

参数
seed初始种子值

在文件 random.hpp97 行定义.

引用了 random_lcd().

成员函数说明

◆ next_float() [1/3]

template<typename T>
T random_lcd::next_float ( )
inlinenoexcept

生成 [0, 1) 范围内的随机浮点数

模板参数
T浮点类型
返回
[0, 1) 范围内的随机浮点数

在文件 random.hpp177 行定义.

引用了 generate(), is_floating_point_v , 以及 numeric_traits< T, Dummy >::max().

被这些函数引用 next_float() , 以及 next_float().

◆ next_float() [2/3]

template<typename T>
T random_lcd::next_float ( T max)
inlinenoexcept

生成 [0, max) 范围内的随机浮点数

模板参数
T浮点类型
参数
max上限(不包含)
返回
[0, max) 范围内的随机浮点数

在文件 random.hpp206 行定义.

引用了 max() , 以及 next_float().

◆ next_float() [3/3]

template<typename T>
T random_lcd::next_float ( T min,
T max )
inlinenoexcept

生成 [min, max) 范围内的随机浮点数

模板参数
T浮点类型
参数
min下限(包含)
max上限(不包含)
返回
[min, max) 范围内的随机浮点数

在文件 random.hpp192 行定义.

引用了 max(), min() , 以及 next_float().

◆ next_int() [1/3]

template<typename T>
T random_lcd::next_int ( )
inlinenoexcept

生成完整范围的随机整数

模板参数
T整形类型
返回
完整范围的随机整数

在文件 random.hpp143 行定义.

引用了 generate() , 以及 is_integral_v.

◆ next_int() [2/3]

template<typename T>
T random_lcd::next_int ( T max)
inlinenoexcept

生成 [0, max) 范围内的随机整数

模板参数
T整形类型
参数
max上限(不包含)
返回
[0, max) 范围内的随机整数

在文件 random.hpp107 行定义.

引用了 is_integral_v , 以及 max().

被这些函数引用 next_int() , 以及 shuffle().

◆ next_int() [3/3]

template<typename T>
T random_lcd::next_int ( T min,
T max )
inlinenoexcept

生成 [min, max) 范围内的随机整数

模板参数
T整形类型
参数
min下限(包含)
max上限(不包含)
返回
[min, max) 范围内的随机整数

在文件 random.hpp130 行定义.

引用了 max(), min() , 以及 next_int().

◆ next_uint64() [1/2]

uint64_t random_lcd::next_uint64 ( )
inlinenoexcept

生成完整范围的随机 64 位整数

返回
完整范围的随机 64 位整数

在文件 random.hpp169 行定义.

◆ next_uint64() [2/2]

uint64_t random_lcd::next_uint64 ( uint64_t max)
inlinenoexcept

生成 [0, max) 范围内的随机 64 位整数

参数
max上限(不包含)
返回
[0, max) 范围内的随机 64 位整数

在文件 random.hpp153 行定义.

引用了 max().


该类的文档由以下文件生成: