14 template <
typename RandomGenerator>
21 template <
typename Iter_weight,
typename Iter>
22 Iter
select(Iter_weight start_w, Iter_weight end_w, Iter start)
24 auto dis = std::discrete_distribution<>(start_w, end_w);
25 std::advance(start, dis(
gen_));
29 template <
typename Iter_weight,
typename Iter>
30 Iter
operator()(Iter_weight start_w, Iter_weight end_w, Iter start)
32 return select(start_w, end_w, start);
41 template <
typename RandomGenerator>
49 template <
typename Iter>
53 = std::uniform_int_distribution<>(0, std::distance(start, end) - 1);
54 std::advance(start, dis(
gen_));
59 template <
typename Iter>
66 template <
typename Container>
67 auto operator()(
const Container& c) -> decltype(*std::begin(c))
69 return *
select(std::begin(c), std::end(c));
73 template <
typename Container>
74 auto pop(Container& c) ->
typename Container::value_type
76 auto i =
select(std::begin(c), std::end(c));
86 template <
typename RandomGenerator>
Iter select(Iter_weight start_w, Iter_weight end_w, Iter start)
Iter operator()(Iter_weight start_w, Iter_weight end_w, Iter start)
std::mt19937 & make_random_engine()
Generate a unique random device.
random_selector(RandomGenerator &g)
Random selector on container, using discrete distribution.
Iter select(Iter start, Iter end)
A randomly selected iterator in [start, end).
discrete_chooser(RandomGenerator &g)
Random selector on container, using uniform distribution.
auto operator()(const Container &c) -> decltype(*std::begin(c))
A randomly selected member of c.
auto pop(Container &c) -> typename Container::value_type
A randomly selected member of c. Remove it from c.
random_selector< RandomGenerator > make_random_selector(RandomGenerator &g)
Iter operator()(Iter start, Iter end)
A randomly selected iterator in [start, end).