33 #include <casacore/casa/aips.h>
34 #include <casacore/casa/Arrays/ArrayFwd.h>
35 #include <casacore/casa/Containers/Block.h>
36 #include <casacore/casa/Utilities/ValType.h>
37 #include <casacore/casa/Utilities/Compare.h>
38 #include <casacore/casa/Utilities/CountedPtr.h>
370 template <
typename T>
372 template <
typename T>
374 template <
typename T>
383 void addKey (
const void* data, DataType,
uInt increment,
int options);
401 void merge (T* inx, T* tmp, T size, T* index,
438 inline void swap (T index1, T index2, T* indices)
const
440 T t = indices[index1];
441 indices[index1] = indices[index2];
abstract base class for comparing two objects
Referenced counted pointer for constant data.
A drop-in replacement for Block<T*>.
int order() const
Get the sort order.
uInt tryGenSort(Vector< uInt > &indexVector, uInt nrrec, int opt) const
Try if GenSort can be used for this single key.
BaseCompare * cmpObj_p
comparison object; use raw pointer for performance
SortKey(const void *data, const CountedPtr< BaseCompare > &, uInt increment, int order)
Define a sort key in a given data array using the indicated comparison object, stride and sort order.
CountedPtr< BaseCompare > ccmpObj_p
comparison object; use CountedPtr for memory management
uInt64 tryGenSort(Vector< uInt64 > &indexVector, uInt64 nrrec, int opt) const
SortKey(const SortKey &)
Copy constructor (copy semantics).
const void * data_p
address of first data point
int order_p
sort order; -1 = ascending, 1 = descending
uInt incr_p
increment for next data point
SortKey & operator=(const SortKey &)
Assignment (copy semantics).
Sort on one or more keys, ascending and/or descending.
uInt64 unique(Vector< uInt64 > &uniqueVector, const Vector< uInt64 > &indexVector) const
Option
Enumerate the sort options:
T heapSortNoDup(T nr, T *indices) const
void addKey(const void *data, DataType, uInt increment, int options)
Add a sort key giving a data type and stride or the sort key.
uInt64 sort(Vector< uInt64 > &indexVector, uInt64 nrrec, int options=DefaultSort, Bool tryGenSort=True) const
int compareChangeIdx(T i1, T i2, size_t &idxComp) const
As compare() but it also gives back the index of the first comparison function that didn't match.
T parSort(int nthr, T nrrec, T *inx) const
Do a merge sort, if possible in parallel using OpenMP.
void sortKey(uInt offset, const CountedPtr< BaseCompare > &, Order=Ascending)
T doUnique(Vector< T > &uniqueVector, Vector< size_t > &changeKey, const Vector< T > &indexVector) const
void copy(const Sort &that)
Copy that Sort object to this.
uInt unique(Vector< uInt > &uniqueVector, uInt nrrec) const
Get all unique records in a sorted array.
T insSort(T nr, T *indices) const
Do an insertion sort, optionally skipping duplicates.
uInt unique(Vector< uInt > &uniqueVector, const Vector< uInt > &indexVector) const
T doSort(Vector< T > &indexVector, T nrrec, int options=DefaultSort, Bool tryGenSort=True) const
uInt unique(Vector< uInt > &uniqueVector, Vector< size_t > &changeKey, const Vector< uInt > &indexVector) const
T quickSort(T nr, T *indices) const
Do a quicksort, optionally skipping duplicates (qkSort is the actual quicksort function).
void merge(T *inx, T *tmp, T size, T *index, T nparts) const
int compare(T index1, T index2) const
Compare 2 records based on the comparison functions.
T heapSort(T nr, T *indices) const
Do a heapsort, optionally skipping duplicates.
void sortKey(uInt offset, DataType, Order=Ascending)
void sortKey(const void *data, DataType, uInt increment=0, Order=Ascending)
Define a sort key (the most significant key should be defined first).
uInt64 unique(Vector< uInt64 > &uniqueVector, uInt64 nrrec) const
Order
Enumerate the sort order:
T quickSortNoDup(T nr, T *indices) const
Sort & operator=(const Sort &)
Assignment (copy semantics).
void swap(T index1, T index2, T *indices) const
Swap 2 indices.
T doUnique(Vector< T > &uniqueVector, const Vector< T > &indexVector) const
Sort(const void *data, uInt elementSize)
Construct a Sort object for the given data array with elements of elementSize bytes.
T doUnique(Vector< T > &uniqueVector, T nrrec) const
uInt sort(Vector< uInt > &indexVector, uInt nrrec, int options=DefaultSort, Bool tryGenSort=True) const
Sort the data array of nrrec records.
uInt64 unique(Vector< uInt64 > &uniqueVector, Vector< size_t > &changeKey, const Vector< uInt64 > &indexVector) const
T insSortNoDup(T nr, T *indices) const
Sort()
The default constructor can be used when the data is only passed in via function sortKey.
PtrBlock< SortKey * > keys_p
Sort(const Sort &)
Copy constructor (copy semantics).
void qkSort(T nr, T *indices) const
void sortKey(const void *data, const CountedPtr< BaseCompare > &, uInt increment, Order=Ascending)
void siftDown(T low, T up, T *indices) const
Siftdown algorithm for heapsort.
this file contains all the compiler specific defines
bool Bool
Define the standard types used by Casacore.
unsigned long long uInt64