28 #ifndef CASA_GENSORT_H
29 #define CASA_GENSORT_H
31 #include <casacore/casa/aips.h>
32 #include <casacore/casa/Arrays/ArrayFwd.h>
33 #include <casacore/casa/Utilities/Sort.h>
38 template<
class T>
class Block;
151 int options = 0,
int nthread = 0);
154 static inline void swap (T&, T&);
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);
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>
size_t nelements() const
The number of elements contained in this Block<T>.
General indirect sort functions.
static INX insSortAscNoDup(INX *inx, const T *, INX nr)
Insertion sort in ascending order allowing no duplicates.
static INX quickSort(INX *inx, const T *data, INX nr, Sort::Order, int options)
Sort container using quicksort.
static INX sort(Vector< INX > &indexVector, const Array< T > &data, Sort::Order=Sort::Ascending, int options=Sort::QuickSort)
Sort a C-array containing nr T-type objects.
static void heapSortAsc(INX *inx, const T *, INX nr)
Heapsort in ascending order.
static void swapInx(INX &index1, INX &index2)
Swap 2 indices.
static INX insSort(INX *inx, const T *data, INX nr, Sort::Order, int options)
Sort container using insertion sort.
static INX insSortAsc(INX *inx, const T *, INX nr, int option)
Insertion sort in ascending order.
static INX sort(Vector< INX > &indexVector, const Block< T > &data, INX nr, Sort::Order=Sort::Ascending, int options=Sort::QuickSort)
Sort a C-array containing nr T-type objects.
static INX heapSort(INX *inx, const T *data, INX nr, Sort::Order, int options)
Sort container using heapsort.
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 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 INX * merge(const T *data, INX *inx, INX *tmp, INX nrrec, INX *index, INX nparts)
Thedata buffer is divided in nparts parts.
static INX kthLargest(T *data, INX nr, INX k)
Find the index of the k-th largest value.
static int isAscending(const T *data, INX index1, INX index2)
Check if 2 values are in ascending order.
static void quickSortAsc(INX *inx, const T *, INX nr, Bool multiThread=False, Int rec_lim=128)
Quicksort in ascending order.
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 uInt insSortAscDup(T *, Int)
Insertion sort in ascending order allowing duplicates.
static uInt sort(T *, uInt nr, Sort::Order=Sort::Ascending, int options=0)
Sort a C-array containing nr T-type objects.
static uInt quickSort(T *, uInt nr, Sort::Order=Sort::Ascending, int options=0)
Sort C-array using quicksort.
static uInt sort(Block< T > &, uInt nr, Sort::Order=Sort::Ascending, int options=0)
static void reverse(T *data, const T *res, uInt nrrec)
Reverse the elements in res and put them into data.
static void heapAscSiftDown(Int, Int, T *)
Helper function for ascending heapsort.
static T * merge(T *data, T *tmp, uInt nrrec, uInt *index, uInt nparts)
Thedata buffer is divided in nparts parts.
static uInt sort(Array< T > &, Sort::Order=Sort::Ascending, int options=0)
static void swap(T &, T &)
Swap 2 elements in array.
static uInt insSort(T *, uInt nr, Sort::Order=Sort::Ascending, int options=0)
Sort C-array using insertion sort.
static uInt heapSort(T *, uInt nr, Sort::Order=Sort::Ascending, int options=0)
Sort C-array using heapsort.
static void quickSortAsc(T *, Int, Bool multiThread=False, Int rec_lim=128)
Quicksort in ascending order.
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 void heapSortAsc(T *, Int)
Heapsort in ascending order.
static uInt insSortAsc(T *, Int, int option)
Insertion sort in ascending order.
static uInt insSortAscNoDup(T *, Int)
Insertion sort in ascending order allowing no duplicates.
static T kthLargest(T *data, uInt nr, uInt k)
Find the k-th largest value.
Order
Enumerate the sort order:
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...
this file contains all the compiler specific defines
bool Bool
Define the standard types used by Casacore.