Skip to content
Snippets Groups Projects
Commit 9ea05f83 authored by mattijs's avatar mattijs
Browse files

moved sort from List to UList

parent 7df47610
Branches
Tags
No related merge requests found
......@@ -35,8 +35,6 @@ License
#include "BiIndirectList.H"
#include "contiguous.H"
#include <algorithm>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
......@@ -442,34 +440,6 @@ void Foam::List<T>::transfer(SortableList<T>& a)
}
template<class T>
void Foam::sort(List<T>& a)
{
std::sort(a.begin(), a.end());
}
template<class T, class Cmp>
void Foam::sort(List<T>& a, const Cmp& cmp)
{
std::sort(a.begin(), a.end(), cmp);
}
template<class T>
void Foam::stableSort(List<T>& a)
{
std::stable_sort(a.begin(), a.end());
}
template<class T, class Cmp>
void Foam::stableSort(List<T>& a, const Cmp& cmp)
{
std::stable_sort(a.begin(), a.end(), cmp);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
// Assignment to UList operator. Takes linear time.
......
......@@ -248,18 +248,6 @@ public:
template<class T>
List<T> readList(Istream&);
template<class T>
void sort(List<T>&);
template<class T, class Cmp>
void sort(List<T>&, const Cmp&);
template<class T>
void stableSort(List<T>&);
template<class T, class Cmp>
void stableSort(List<T>&, const Cmp&);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -30,6 +30,8 @@ License
#include "ListLoopM.H"
#include "contiguous.H"
#include <algorithm>
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T>
......@@ -116,6 +118,34 @@ Foam::label Foam::UList<T>::byteSize() const
}
template<class T>
void Foam::sort(UList<T>& a)
{
std::sort(a.begin(), a.end());
}
template<class T, class Cmp>
void Foam::sort(UList<T>& a, const Cmp& cmp)
{
std::sort(a.begin(), a.end(), cmp);
}
template<class T>
void Foam::stableSort(UList<T>& a)
{
std::stable_sort(a.begin(), a.end());
}
template<class T, class Cmp>
void Foam::stableSort(UList<T>& a, const Cmp& cmp)
{
std::stable_sort(a.begin(), a.end(), cmp);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class T>
......
......@@ -320,6 +320,18 @@ public:
);
};
template<class T>
void sort(UList<T>&);
template<class T, class Cmp>
void sort(UList<T>&, const Cmp&);
template<class T>
void stableSort(UList<T>&);
template<class T, class Cmp>
void stableSort(UList<T>&, const Cmp&);
// Reverse the first n elements of the list
template<class T>
inline void reverse(UList<T>&, const label n);
......
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