23 template <
class RandomIt,
class URBG>
24 void shuffle(RandomIt first, RandomIt last, URBG&& g)
26 typedef typename std::iterator_traits<RandomIt>::difference_type diff_t;
27 typedef std::uniform_int_distribution<diff_t> distr_t;
28 typedef typename distr_t::param_type param_t;
30 diff_t n = last - first;
31 for (diff_t i = n - 1; i > 0; --i)
32 std::swap(first[i], first[D(g, param_t(0, i))]);
38 template <
class RandomIt>
39 void shuffle(RandomIt first, RandomIt last)
41 std::random_device rd;
void shuffle(RandomIt first, RandomIt last, URBG &&g)
Uniform shuffle a sequence.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.