Commit 7a5c6703 authored by Philip Trettner's avatar Philip Trettner

added tg::shuffle

parent ea2785c9
......@@ -3,4 +3,5 @@
#include <typed-geometry/functions/random/gaussian.hh>
#include <typed-geometry/functions/random/random.hh>
#include <typed-geometry/functions/random/random_choice.hh>
#include <typed-geometry/functions/random/shuffle.hh>
#include <typed-geometry/functions/random/uniform.hh>
#pragma once
#include <typed-geometry/types/span.hh>
namespace tg
template <class Rng, class T>
constexpr void shuffle(Rng& rng, span<T> range)
for (size_t i = 1; i < range.size(); ++i)
auto j = rng() % (i + 1);
if (i != j)
detail::swap(range[i], range[j]);
template <class Rng, class Range>
constexpr void shuffle(Rng& rng, Range& range)
shuffle(rng, tg::span(range));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment