MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / staticRandomShuffle

Function staticRandomShuffle

source/core/StarStaticRandom.hpp:136–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134
135template <typename Container, typename T, typename... TL>
136void staticRandomShuffle(Container& container, T const& d, TL const&... rest) {
137 auto begin = container.begin();
138 auto end = container.end();
139 auto it = begin;
140 for (int i = 1, mix = 0; ++it != end; ++i) {
141 int off = staticRandomU32Range(0, i, ++mix, d, rest...);
142 if (off != i)
143 std::swap(*it, *(begin + off));
144 }
145}
146
147}

Callers 1

Calls 3

staticRandomU32RangeFunction · 0.85
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected