diff --git a/src/OpenFOAM/containers/Lists/UList/UList.H b/src/OpenFOAM/containers/Lists/UList/UList.H index 7ee7c4e05d..06ef4cbb61 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.H +++ b/src/OpenFOAM/containers/Lists/UList/UList.H @@ -348,6 +348,10 @@ void stableSort(UList&, const Cmp&); template void shuffle(UList&); +// Reverse the first n elements of the list +template +inline void reverse(UList&, const label n); + // Reverse all the elements of the list template inline void reverse(UList&); diff --git a/src/OpenFOAM/containers/Lists/UList/UListI.H b/src/OpenFOAM/containers/Lists/UList/UListI.H index 8c6a1d43e6..3994b3deec 100644 --- a/src/OpenFOAM/containers/Lists/UList/UListI.H +++ b/src/OpenFOAM/containers/Lists/UList/UListI.H @@ -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::empty() const // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // +template +inline void Foam::reverse(UList& ul, const label n) +{ + for (int i=0; i inline void Foam::reverse(UList& ul) { - inplaceReverseList(ul); + reverse(ul, ul.size()); }