TTK
Loading...
Searching...
No Matches
core
base
common
Shuffle.h
Go to the documentation of this file.
1
#include <cstdlib>
2
#include <vector>
3
4
namespace
ttk
{
12
template
<
typename
T,
typename
U>
13
void
shuffle
(std::vector<T> &toShuffle, U &&rng) {
14
for
(
size_t
i = toShuffle.size() - 1; i >= 1; i--) {
15
const
auto
j = rng() % i;
16
std::swap(toShuffle[i], toShuffle[j]);
17
}
18
}
19
}
// namespace ttk
ttk
The Topology ToolKit.
Definition
AbstractTriangulation.h:51
ttk::shuffle
void shuffle(std::vector< T > &toShuffle, U &&rng)
Platform-independent alternative to std::shuffle implementing the Fisher-Yates shuffle algorithm.
Definition
Shuffle.h:13
Generated on Thu Sep 26 2024 06:50:17 for TTK by
1.9.8