mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 10:26:28 +01:00
Core/Util: Added iterator range overload for Trinity::Containers::RandomShuffle
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user