Sort Namespace Reference


Detailed Description

Some support for sorting small arrays.


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.
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.


Function Documentation

template<typename T, typename Cmp, typename M>
void Sort::insertion ( const int  n,
T *  array,
const Cmp &  cmp,
const M *const   mask 
) [inline]

Insertion sort.

Sorts using Cmp which defaults to std::less<T>(). Use only for small ~(n < 20) arrays.

Template Parameters:
T Type of element
Cmp Comparison functor. Requires operator()(T&, T&).
M Type of mask
Parameters:
[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

template<typename T, typename Cmp>
void Sort::insertion ( const int  n,
T *  array,
const Cmp &  cmp 
) [inline]

template<typename T>
void Sort::insertion ( const int  n,
T *  array 
) [inline]

template<typename Mv>
void Sort::rearrangeToIndex ( const int  n,
int *const   index,
Mv &  mv 
) [inline]

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

Template Parameters:
Mv Class for moving elements and saving/restoring elements. Needs members 'copy', 'save', and 'restore'. See Move1Array for example.
Parameters:
[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.


Generated on Sat Sep 23 03:28:08 2017 for Chombo + EB + MF by  doxygen 1.5.5