From 08b5a0586aadd26b6ffa050e8538fd9ebb57591b Mon Sep 17 00:00:00 2001 From: Shauren Date: Mon, 3 Jan 2022 12:48:40 +0100 Subject: Core/Util: Added iterator range overload for Trinity::Containers::RandomShuffle --- src/common/Utilities/Containers.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/common/Utilities/Containers.h') 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 @@ -166,6 +166,20 @@ namespace Trinity return SelectRandomWeightedContainerElement(container, weights); } + /** + * @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 + inline void RandomShuffle(Iterator begin, Iterator end) + { + std::shuffle(begin, end, RandomEngine::Instance()); + } + /** * @fn void Trinity::Containers::RandomShuffle(C& container) * @@ -176,7 +190,7 @@ namespace Trinity template inline void RandomShuffle(C& container) { - std::shuffle(std::begin(container), std::end(container), RandomEngine::Instance()); + RandomShuffle(std::begin(container), std::end(container)); } /** -- cgit v1.2.3