CMR  1.3.0
Functions
sort.h File Reference
#include "env_internal.h"

Go to the source code of this file.

Functions

CMR_ERROR CMRsort (CMR *cmr, size_t length, void *array, size_t elementSize, int(*compare)(const void *, const void *))
 Sorts an array. More...
 
CMR_ERROR CMRsort2 (CMR *cmr, size_t length, void *array1, size_t elementSize1, void *array2, size_t elementSize2, int(*compare)(const void **, const void **))
 Sorts two arrays simultaneously. More...
 

Function Documentation

◆ CMRsort()

CMR_ERROR CMRsort ( CMR cmr,
size_t  length,
void *  array,
size_t  elementSize,
int(*)(const void *, const void *)  compare 
)

Sorts an array.

The user must provide a compare function that is called several times with pointers into the first array. The arguments must be dereferenced once in order to access the actual element.

Parameters
cmrCMR environment.
lengthNumber of elements in both arrays.
arrayPointer to the first element of the array.
elementSizeSize (in bytes) of each element of the array.
compareComparison function for comparing two elements.

◆ CMRsort2()

CMR_ERROR CMRsort2 ( CMR cmr,
size_t  length,
void *  array1,
size_t  elementSize1,
void *  array2,
size_t  elementSize2,
int(*)(const void **, const void **)  compare 
)

Sorts two arrays simultaneously.

Sorts two arrays using the qsort function from the C library. The user must provide a compare function that is called several times with pointers to pointers into the first array. Hence, the arguments must be dereferenced twice in order to access the actual element.

Parameters
cmrCMR environment.
lengthNumber of elements in both arrays.
array1Pointer to the first element of the first array.
elementSize1Size (in bytes) of each element of the first array.
array2Pointer to the first element of the second array.
elementSize2Size (in bytes) of each element of the second array.
compareComparison function for comparing two elements.