aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2022-01-03 12:48:40 +0100
committerShauren <shauren.trinity@gmail.com>2022-01-03 12:48:40 +0100
commit08b5a0586aadd26b6ffa050e8538fd9ebb57591b (patch)
tree56dc2c02e17626d331af1ab6fd7b84f30c6e3b21
parent3a67e376811743be208da4aab8a9e452e1ae637e (diff)
Core/Util: Added iterator range overload for Trinity::Containers::RandomShuffle
-rw-r--r--src/common/Utilities/Containers.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/common/Utilities/Containers.h b/src/common/Utilities/Containers.h
index c037ffd243b..ca0c9c49263 100644
--- a/src/common/Utilities/Containers.h
+++ b/src/common/Utilities/Containers.h
@@ -167,6 +167,20 @@ namespace Trinity
}
/**
+ * @fn void Trinity::Containers::RandomShuffle(Iterator begin, Iterator end)
+ *
+ * @brief Reorder the elements of the iterator range randomly.
+ *
+ * @param begin Beginning of the range to reorder
+ * @param end End of the range to reorder
+ */
+ template<class Iterator>
+ inline void RandomShuffle(Iterator begin, Iterator end)
+ {
+ std::shuffle(begin, end, RandomEngine::Instance());
+ }
+
+ /**
* @fn void Trinity::Containers::RandomShuffle(C& container)
*
* @brief Reorder the elements of the container randomly.
@@ -176,7 +190,7 @@ namespace Trinity
template<class C>
inline void RandomShuffle(C& container)
{
- std::shuffle(std::begin(container), std::end(container), RandomEngine::Instance());
+ RandomShuffle(std::begin(container), std::end(container));
}
/**