ENH: UList shuffle function to randomly reorder a list.

This commit is contained in:
graham
2010-11-10 10:50:59 +00:00
parent 601142ce5d
commit d1cbc06c67
2 changed files with 10 additions and 0 deletions

View File

@ -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 * * * * * * * * * * * * * //
template<class T>

View File

@ -344,6 +344,9 @@ void stableSort(UList<T>&);
template<class T, class Cmp>
void stableSort(UList<T>&, const Cmp&);
template<class T>
void shuffle(UList<T>&);
// Reverse the first n elements of the list
template<class T>
inline void reverse(UList<T>&, const label n);