mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: Reinstate reverse() function in UList
This commit is contained in:
@ -348,6 +348,10 @@ 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);
|
||||
|
||||
// Reverse all the elements of the list
|
||||
template<class T>
|
||||
inline void reverse(UList<T>&);
|
||||
|
||||
@ -25,7 +25,6 @@ License
|
||||
|
||||
#include "error.H"
|
||||
#include "pTraits.H"
|
||||
#include "ListOps.H"
|
||||
#include "Swap.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
@ -319,10 +318,19 @@ inline bool Foam::UList<T>::empty() const
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline void Foam::reverse(UList<T>& ul, const label n)
|
||||
{
|
||||
for (int i=0; i<n/2; i++)
|
||||
{
|
||||
Swap(ul[i], ul[n-1-i]);
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void Foam::reverse(UList<T>& ul)
|
||||
{
|
||||
inplaceReverseList(ul);
|
||||
reverse(ul, ul.size());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user