Index: src/IceRNG.h |
diff --git a/src/IceRNG.h b/src/IceRNG.h |
index bf01e410d559ffaac0a94fa176f6ff91531cd8bb..a2d8e96fd959bf59c0845103169ec7b2ee1f89f0 100644 |
--- a/src/IceRNG.h |
+++ b/src/IceRNG.h |
@@ -53,6 +53,15 @@ private: |
RandomNumberGenerator &RNG; |
}; |
+// RandomShuffle is an implementation of std::random_shuffle() that |
+// doesn't change across stdlib implementations. Adapted from a |
+// sample implementation at cppreference.com. |
+template <class RandomIt, class RandomFunc> |
+void RandomShuffle(RandomIt First, RandomIt Last, RandomFunc &&RNG) { |
+ for (auto i = Last - First - 1; i > 0; --i) |
+ std::swap(First[i], First[RNG(i + 1)]); |
+} |
+ |
} // end of namespace Ice |
#endif // SUBZERO_SRC_ICERNG_H |