Skip to content
Snippets Groups Projects
Commit 0bd5bc85 authored by graham's avatar graham
Browse files

ENH: UList shuffle function to randomly reorder a list.

parent 9b1788ac
Branches
Tags
No related merge requests found
...@@ -145,6 +145,13 @@ void Foam::stableSort(UList<T>& a, const Cmp& cmp) ...@@ -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>&); ...@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment