17 #ifndef AWALI_MISC_RANDOM_HH
18 # define AWALI_MISC_RANDOM_HH
25 namespace awali {
namespace sttc {
29 template <
typename RandomGenerator = std::default_random_engine>
37 template <
typename Iter>
40 std::uniform_int_distribution<> dis(0, std::distance(start, end) - 1);
41 std::advance(start, dis(gen_));
46 template <
typename Iter>
53 template <
typename Container>
56 return *
select(std::begin(
c), std::end(
c));
60 template <
typename Container>
61 auto pop(Container&
c) ->
typename Container::value_type
63 auto i =
select(std::begin(
c), std::end(
c));
74 template <
typename RandomGenerator = std::default_random_engine>
75 struct random_selector<RandomGenerator>
79 template <
typename RandomGenerator>
80 struct random_selector<RandomGenerator>
The semiring of complex numbers.
Definition: c.hh:44
struct random_selector< RandomGenerator > make_random_selector(const RandomGenerator &g) ATTRIBUTE_PURE
Definition: random.hh:81
Main namespace of Awali.
Definition: ato.hh:22
Iter select(Iter start, Iter end)
A randomly selected iterator in [start, end).
Definition: random.hh:38
Iter operator()(Iter start, Iter end)
A randomly selected iterator in [start, end).
Definition: random.hh:47
auto operator()(const Container &c) -> decltype(*std::begin(c))
A randomly selected member of c.
Definition: random.hh:54
random_selector(const RandomGenerator &g=RandomGenerator())
Definition: random.hh:32
auto pop(Container &c) -> typename Container::value_type
A randomly selected member of c. Remove it from c.
Definition: random.hh:61