Chombo + EB + MF
3.2
|
Some support for sorting small arrays. More...
Classes | |
class | CmpGreaterIndex |
Compares m_a[i] > m_a[j]. More... | |
class | Move1Array |
Mover for use with 'rearrangeToIndex'. More... | |
class | Move2Array |
Mover for use with 'rearrangeToIndex'. More... | |
Functions | |
template<typename T , typename Cmp , typename M > | |
void | insertion (const int n, T *array, const Cmp &cmp, const M *const mask) |
Insertion sort. More... | |
template<typename T , typename Cmp > | |
void | insertion (const int n, T *array, const Cmp &cmp) |
template<typename T > | |
void | insertion (const int n, T *array) |
template<typename Mv > | |
void | rearrangeToIndex (const int n, int *const index, Mv &mv) |
Rearrange arrays to a sorted index. More... | |
Some support for sorting small arrays.
void Sort::insertion | ( | const int | n, |
T * | array, | ||
const Cmp & | cmp, | ||
const M *const | mask | ||
) |
Insertion sort.
Sorts using Cmp which defaults to std::less<T>(). Use only for small ~(n < 20) arrays.
T | Type of element |
Cmp | Comparison functor. Requires operator()(T&, T&). |
M | Type of mask |
[in] | n | Number of elements to sort |
[in] | array | Array to sort |
[in] | cmp | Comparison bool operator()(i, j) to determine if element array[i] belongs before array[j] |
[in] | mask | Only sort elements were mask = true. Unused if set to null |
void Sort::insertion | ( | const int | n, |
T * | array, | ||
const Cmp & | cmp | ||
) |
void Sort::insertion | ( | const int | n, |
T * | array | ||
) |
void Sort::rearrangeToIndex | ( | const int | n, |
int *const | index, | ||
Mv & | mv | ||
) |
Rearrange arrays to a sorted index.
If an index to an array has been sorted instead of the actual array, this allows for rearranging other arrays in the exact same manner that the index was rearranged during sorting. Note that the index array is reverted to a sequential order during this process
Mv | Class for moving elements and saving/restoring elements. Needs members 'copy', 'save', and 'restore'. See Move1Array for example. |
[in] | n | Number of elements to rearrange |
[in] | index | Array of indices describing where elements are to be moved. |
[out] | index | index[0] < index[...] < index[n] |
[in] | mv | Class for moving elements and saving/restoring elements. |