Commit f46de13c authored by laurence's avatar laurence
Browse files

BUG: Reinstate reverse() function in UList

parent cc1a3e58
......@@ -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());
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment