RandX 1.4.3
基于 xoshiro/xoroshiro 算法族的纯头文件伪随机数生成器库
载入中...
搜索中...
未找到
基础生成

RandInt / RandReal / RandBool / RandChar / RandBits 更多...

函数

template<std::integral T = int>
RandX::RandInt (T min, T max)
 生成 [min, max] 范围内的随机整数
template<std::integral T = int>
RandX::RandInt (T max)
 生成 [0, max] 范围内的随机整数
template<std::floating_point T = double>
RandX::RandReal (T min=T{0}, T max=T{1})
 生成 [min, max) 范围内的随机浮点数
bool RandX::RandBool (double p=0.5)
 生成随机布尔值
template<class Engine>
bool RandX::RandBool (Engine &engine, double p=0.5)
 生成随机布尔值(指定引擎重载)
bool RandX::RandBernoulli (double p=0.5)
 伯努利分布(RandBool 的别名封装,对齐 <random> 命名)
template<class Engine>
bool RandX::RandBernoulli (Engine &engine, double p=0.5)
 伯努利分布(指定引擎重载)
template<detail::Character CharT>
CharT RandX::RandChar (CharT min, CharT max)
 生成 [min, max] 范围内的随机字符
template<detail::Character CharT = char>
CharT RandX::RandChar (CharT max)
 生成 [CharT{}, max] 范围内的随机字符
template<detail::Character CharT, class Engine>
CharT RandX::RandChar (Engine &engine, CharT min, CharT max)
 生成 [min, max] 范围内的随机字符(指定引擎重载)
template<detail::Character CharT = char, class Engine>
CharT RandX::RandChar (Engine &engine, CharT max)
 生成 [CharT{}, max] 范围内的随机字符(指定引擎重载)

详细描述

RandInt / RandReal / RandBool / RandChar / RandBits

函数说明

◆ RandBernoulli() [1/2]

bool RandX::RandBernoulli ( double p = 0.5)
inlinenodiscard

伯努利分布(RandBool 的别名封装,对齐 <random> 命名)

参数
p成功概率(默认 0.5)
返回
以概率 p 返回 true
函数调用图:

◆ RandBernoulli() [2/2]

template<class Engine>
bool RandX::RandBernoulli ( Engine & engine,
double p = 0.5 )
inlinenodiscard

伯努利分布(指定引擎重载)

参数
engine自定义随机数引擎
p成功概率(默认 0.5)
返回
以概率 p 返回 true
函数调用图:

◆ RandBool() [1/2]

bool RandX::RandBool ( double p = 0.5)
inlinenodiscard

生成随机布尔值

参数
p为 true 的概率(默认 0.5)
返回
以概率 p 返回 true
函数调用图:

◆ RandBool() [2/2]

template<class Engine>
bool RandX::RandBool ( Engine & engine,
double p = 0.5 )
inlinenodiscard

生成随机布尔值(指定引擎重载)

参数
engine自定义随机数引擎
p为 true 的概率(默认 0.5)
返回
以概率 p 返回 true

◆ RandChar() [1/4]

template<detail::Character CharT = char>
CharT RandX::RandChar ( CharT max)
inlinenodiscard

生成 [CharT{}, max] 范围内的随机字符

参数
max上界字符(含)
返回
均匀分布于 [CharT{}, max] 的随机字符
函数调用图:

◆ RandChar() [2/4]

template<detail::Character CharT>
CharT RandX::RandChar ( CharT min,
CharT max )
inlinenodiscard

生成 [min, max] 范围内的随机字符

参数
min下界字符(含)
max上界字符(含)
返回
均匀分布于 [min, max] 的随机字符
注解
内部用 int64_t 避免 char32_t 范围(最大 0xFFFFFFFF)溢出 int32_t
函数调用图:

◆ RandChar() [3/4]

template<detail::Character CharT = char, class Engine>
CharT RandX::RandChar ( Engine & engine,
CharT max )
inlinenodiscard

生成 [CharT{}, max] 范围内的随机字符(指定引擎重载)

参数
engine自定义随机数引擎
max上界字符(含)
返回
均匀分布于 [CharT{}, max] 的随机字符
函数调用图:

◆ RandChar() [4/4]

template<detail::Character CharT, class Engine>
CharT RandX::RandChar ( Engine & engine,
CharT min,
CharT max )
inlinenodiscard

生成 [min, max] 范围内的随机字符(指定引擎重载)

参数
engine自定义随机数引擎
min下界字符(含)
max上界字符(含)
返回
均匀分布于 [min, max] 的随机字符

◆ RandInt() [1/2]

template<std::integral T = int>
T RandX::RandInt ( T max)
inlinenodiscard

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

参数
max上界(含)
返回
均匀分布于 [0, max] 的随机整数
函数调用图:

◆ RandInt() [2/2]

template<std::integral T = int>
T RandX::RandInt ( T min,
T max )
inlinenodiscard

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

参数
min下界(含)
max上界(含)
返回
均匀分布于 [min, max] 的随机整数
函数调用图:

◆ RandReal()

template<std::floating_point T = double>
T RandX::RandReal ( T min = T{0},
T max = T{1} )
inlinenodiscard

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

参数
min下界(含,默认 0)
max上界(不含,默认 1)
返回
均匀分布于 [min, max) 的随机浮点数