cpp-toolbox  0.0.1
A toolbox library for C++
Loading...
Searching...
No Matches
toolbox::io::shuffle_policy_t Class Reference

随机打乱采样策略/Shuffle sampling policy More...

#include <sampler.hpp>

Public Member Functions

 shuffle_policy_t (unsigned seed=std::random_device {}())
 构造函数/Constructor
 
void operator() (std::vector< std::size_t > &indices)
 打乱索引/Shuffle indices
 
void set_seed (unsigned seed)
 设置随机种子/Set random seed
 

Detailed Description

随机打乱采样策略/Shuffle sampling policy

使用给定种子对索引进行随机打乱/Randomly shuffles indices with given seed

std::vector<std::size_t> indices = {0, 1, 2, 3};
policy(indices); // indices 顺序被打乱/indices are shuffled
随机打乱采样策略/Shuffle sampling policy
Definition sampler.hpp:44

Constructor & Destructor Documentation

◆ shuffle_policy_t()

toolbox::io::shuffle_policy_t::shuffle_policy_t ( unsigned  seed = std::random_device {}())
inlineexplicit

构造函数/Constructor

Parameters
seed随机种子/Random seed

Member Function Documentation

◆ operator()()

void toolbox::io::shuffle_policy_t::operator() ( std::vector< std::size_t > &  indices)
inline

打乱索引/Shuffle indices

Parameters
indices待打乱的索引数组/Indices array to shuffle

◆ set_seed()

void toolbox::io::shuffle_policy_t::set_seed ( unsigned  seed)
inline

设置随机种子/Set random seed

Parameters
seed新的随机种子/New random seed

The documentation for this class was generated from the following file: