mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: UList shuffle function to randomly reorder a list.
This commit is contained in:
@ -145,6 +145,13 @@ void Foam::stableSort(UList<T>& a, const Cmp& cmp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void Foam::shuffle(UList<T>& a)
|
||||||
|
{
|
||||||
|
std::random_shuffle(a.begin(), a.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|||||||
@ -344,6 +344,9 @@ void stableSort(UList<T>&);
|
|||||||
template<class T, class Cmp>
|
template<class T, class Cmp>
|
||||||
void stableSort(UList<T>&, const Cmp&);
|
void stableSort(UList<T>&, const Cmp&);
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void shuffle(UList<T>&);
|
||||||
|
|
||||||
// Reverse the first n elements of the list
|
// Reverse the first n elements of the list
|
||||||
template<class T>
|
template<class T>
|
||||||
inline void reverse(UList<T>&, const label n);
|
inline void reverse(UList<T>&, const label n);
|
||||||
|
|||||||
Reference in New Issue
Block a user