通过重新排序从其基引擎返回的值生成一个随机顺序。
template<class Engine,
size_t K>
class shuffle_order_engine {
public:
typedef Engine base_type;
typedef typename base_type::result_type result_type;
static constexpr size_t table_size = K;
shuffle_order_engine();
explicit shuffle_order_engine(const base_type& eng);
explicit shuffle_order_engine(result_type x0);
explicit shuffle_order_engine(seed_seq& seq);
void seed();
void seed(result_type x0);
void seed(seed_seq& seq);
const base_type& base() const;
static constexpr result_type min();
static constexpr result_type max();
result_type operator()();
void discard(unsigned long long count);
private:
Engine stored_eng;
result_type stored_arr[K];
result_type stored_y;
};
参数
Engine
存储的引擎类型。K
K引擎参数。
备注
通过重新排列其基本引擎返回的值生成值的此模板选件类描述 复式引擎。每个构造函数使用基本引擎返回的 K 值填充数组 stored_arr。它在其他值由基本引擎返回的 stored_y 然后存储。所生成的序列的每个元素从 stored_y然后获取,因此,在如下:
数组索引 J 计算为 K * (stored_y - min()) / (max() - min() + 1)。
stored_y 中 stored_arr[J]替换。
stored_arr[j] 中 stored_eng()替换。
引擎处理状态是 stored_eng状态,后跟 stored_arr的 K 元素,后跟 stored_y。
模板参数 K 的值大于零输入到。
要求
标头: <random>
命名空间: std
请参见
参考
shuffle_order_engine::base_type