5#include <Common/assertion.h>
15namespace detail::shuffle
32template<
typename IndexPairConsumer>
34 const std::size_t beginIndex,
35 const std::size_t endIndex,
36 IndexPairConsumer consumer)
38 PH_ASSERT_LE(beginIndex, endIndex);
40 for(std::size_t i = beginIndex; i < endIndex; ++i)
48 typename RandomIterator,
51 RandomIterator begin, RandomIterator end,
52 Swapper swapper = Swapper())
54 PH_ASSERT(begin <= end);
55 const auto NUM_ELEMENTS =
static_cast<std::size_t
>(std::distance(begin, end));
60 const std::size_t indexA,
const std::size_t indexB)
62 swapper(begin[indexA], begin[indexB]);
static std::size_t index(std::size_t lowerBound, std::size_t upperBound)
Get a uniform random integer value in [lowerBound, upperBound).
Definition Random.ipp:23
Math functions and utilities.
Definition TransformInfo.h:10
void shuffle_durstenfeld_index_pairs(const std::size_t beginIndex, const std::size_t endIndex, IndexPairConsumer consumer)
Definition shuffle.h:33
void shuffle_durstenfeld(RandomIterator begin, RandomIterator end, Swapper swapper=Swapper())
Definition shuffle.h:50
void operator()(T &a, T &b) const
Definition shuffle.h:21