Core/Util: Added iterator range overload for Trinity::Containers::RandomShuffle

This commit is contained in:
Shauren
2022-01-03 12:48:40 +01:00
parent 3a67e37681
commit 08b5a0586a

View File

@@ -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<class Iterator>
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<class C>
inline void RandomShuffle(C& container)
{
std::shuffle(std::begin(container), std::end(container), RandomEngine::Instance());
RandomShuffle(std::begin(container), std::end(container));
}
/**