28 #ifndef CASA_GENSORT_H
29 #define CASA_GENSORT_H
38 template<
class T>
class Block;
151 int options = 0,
int nthread = 0);
154 static inline void swap (T&, T&);
158 static void reverse (T* data,
const T* res,
uInt nrrec);
228 static INX
kthLargest (T* data, INX nr, INX k);
235 static INX
quickSort (INX* inx,
const T* data,
238 static INX
heapSort (INX* inx,
const T* data,
241 static INX
insSort (INX* inx,
const T* data,
245 static INX
parSort (INX* inx,
const T* data,
250 static inline void swapInx (INX& index1, INX& index2);
260 static INX*
merge (
const T* data, INX* inx, INX* tmp, INX nrrec,
261 INX* index, INX nparts);
265 static inline int isAscending (
const T* data, INX index1, INX index2);
273 static void heapSortAsc (INX* inx,
const T*, INX nr);
278 static INX
insSortAsc (INX* inx,
const T*, INX nr,
int option);
355 template<
class T,
class INX=uInt>
361 template<
class T,
class INX=uInt>
367 template<
class T,
class INX=uInt>
374 template<
class T,
class INX=uInt>
393 template<
class T,
class INX>
400 template<
class T,
class INX>
403 return (data[i] > data[j] || (data[i] == data[j] && i > j));
410 #ifndef CASACORE_NO_AUTO_TEMPLATES
411 #include <casacore/casa/Utilities/GenSort.tcc>
412 #endif //# CASACORE_NO_AUTO_TEMPLATES
A 1-D Specialization of the Array class.
static INX parSort(INX *inx, const T *data, INX nr, Sort::Order, int options, int nthreads=0)
Sort container using parallel merge sort (using OpenMP).
static T * merge(T *data, T *tmp, uInt nrrec, uInt *index, uInt nparts)
Thedata buffer is divided in nparts parts.
static int isAscending(const T *data, INX index1, INX index2)
Check if 2 values are in ascending order.
static INX kthLargest(T *data, INX nr, INX k)
Find the index of the k-th largest value.
static INX sort(Vector< INX > &indexVector, const T *data, INX nr, Sort::Order=Sort::Ascending, int options=Sort::QuickSort)
Sort a C-array containing nr T-type objects.
static void quickSortAsc(INX *inx, const T *, INX nr, Bool multiThread=False, Int rec_lim=128)
Quicksort in ascending order.
static void heapAscSiftDown(INX *inx, INX, INX, const T *)
Helper function for ascending heapsort.
static INX insSortAscDup(INX *inx, const T *, INX nr)
Insertion sort in ascending order allowing duplicates.
static void heapSortAsc(T *, Int)
Heapsort in ascending order.
Order
Enumerate the sort order:
static INX insSortAsc(INX *inx, const T *, INX nr, int option)
Insertion sort in ascending order.
static void heapAscSiftDown(Int, Int, T *)
Helper function for ascending heapsort.
size_t nelements() const
The number of elements contained in this Block<T>.
static uInt insSortAscNoDup(T *, Int)
Insertion sort in ascending order allowing no duplicates.
static uInt parSort(T *, uInt nr, Sort::Order=Sort::Ascending, int options=0, int nthread=0)
Sort C-array using parallel merge sort (using OpenMP).
static INX heapSort(INX *inx, const T *data, INX nr, Sort::Order, int options)
Sort container using heapsort.
static INX quickSort(INX *inx, const T *data, INX nr, Sort::Order, int options)
Sort container using quicksort.
static void reverse(T *data, const T *res, uInt nrrec)
Reverse the elements in res and put them into data.
static uInt insSortAsc(T *, Int, int option)
Insertion sort in ascending order.
General in-place sort functions.
static void heapSortAsc(INX *inx, const T *, INX nr)
Heapsort in ascending order.
static uInt heapSort(T *, uInt nr, Sort::Order=Sort::Ascending, int options=0)
Sort C-array using heapsort.
bool Bool
Define the standard types used by Casacore.
static void swap(T &, T &)
Swap 2 elements in array.
static uInt quickSort(T *, uInt nr, Sort::Order=Sort::Ascending, int options=0)
Sort C-array using quicksort.
static INX * merge(const T *data, INX *inx, INX *tmp, INX nrrec, INX *index, INX nparts)
Thedata buffer is divided in nparts parts.
static void swapInx(INX &index1, INX &index2)
Swap 2 indices.
static T kthLargest(T *data, uInt nr, uInt k)
Find the k-th largest value.
static INX insSort(INX *inx, const T *data, INX nr, Sort::Order, int options)
Sort container using insertion sort.
General indirect sort functions.
static uInt sort(T *, uInt nr, Sort::Order=Sort::Ascending, int options=0)
Sort a C-array containing nr T-type objects.
static void quickSortAsc(T *, Int, Bool multiThread=False, Int rec_lim=128)
Quicksort in ascending order.
static uInt insSortAscDup(T *, Int)
Insertion sort in ascending order allowing duplicates.
static INX insSortAscNoDup(INX *inx, const T *, INX nr)
Insertion sort in ascending order allowing no duplicates.
static uInt insSort(T *, uInt nr, Sort::Order=Sort::Ascending, int options=0)
Sort C-array using insertion sort.
uInt genSort(T *data, uInt nr, Sort::Order order=Sort::Ascending, int options=0)
Global in-place sort functions The following global functions are easier to use than the static GenSo...