dl
dl::Random类 参考

随机数 更多...

#include <dl_random.h>

静态 Public 成员函数

static void SetSeed (uint32_t seed)
 设置随机数种子
 
template<typename T>
static T Float (T min, T max)
 返回[min,max)区间的 浮点数随机值
 
template<typename T>
static T Integer (T min, T max)
 返回[min,max]区间的 随机整数
 
static bool Bool ()
 
static int Int (int min, int max)
 返回[min,max]区间的 int型整数
 
static unsigned Uint (unsigned min, unsigned max)
 返回[min,max]区间的 unsigned型整数
 
template<typename C>
static auto & Select (C &container)
 从容器随机选择一个
 

详细描述

随机数

在文件 dl_random.h 第 18 行定义.

成员函数说明

◆ Bool()

static bool dl::Random::Bool ( )
inlinestatic

在文件 dl_random.h 第 78 行定义.

◆ Float()

template<typename T>
static T dl::Random::Float ( T min,
T max )
inlinestatic

返回[min,max)区间的 浮点数随机值

注解
如果min等于max,则返回min。如果min大于max则交换位置后比较,但会发出一条警告。

在文件 dl_random.h 第 41 行定义.

◆ Int()

static int dl::Random::Int ( int min,
int max )
inlinestatic

返回[min,max]区间的 int型整数

在文件 dl_random.h 第 86 行定义.

◆ Integer()

template<typename T>
static T dl::Random::Integer ( T min,
T max )
inlinestatic

返回[min,max]区间的 随机整数

注解
如果min等于max,则返回min。如果min大于max则交换位置后比较,但会发出一条警告。

在文件 dl_random.h 第 62 行定义.

◆ Select()

template<typename C>
static auto & dl::Random::Select ( C & container)
inlinestatic

从容器随机选择一个

参数
[in]container容器(不能为空)
返回值
返回引用

在文件 dl_random.h 第 104 行定义.

◆ SetSeed()

static void dl::Random::SetSeed ( uint32_t seed)
inlinestatic

设置随机数种子

注解
0会随机生成一个种子

在文件 dl_random.h 第 25 行定义.

◆ Uint()

static unsigned dl::Random::Uint ( unsigned min,
unsigned max )
inlinestatic

返回[min,max]区间的 unsigned型整数

在文件 dl_random.h 第 93 行定义.


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