QSort preprocessor metaprogram. More...
Go to the source code of this file.
Defines | |
#define | VL_QSORT_array VL_QSORT_type* |
#define | VL_QSORT_array_const VL_QSORT_type const* |
#define | VL_QSORT_cmp VL_XCAT(VL_QSORT_prefix, _cmp) |
#define | VL_QSORT_swap VL_XCAT(VL_QSORT_prefix, _swap) |
Functions | |
VL_INLINE VL_QSORT_type | VL_QSORT_cmp (VL_QSORT_array_const array, vl_uindex indexA, vl_uindex indexB) |
Compare two array elements. | |
VL_INLINE void | VL_QSORT_swap (VL_QSORT_array array, vl_uindex indexA, vl_uindex indexB) |
Swap two array elements. |
QSort preprocessor metaprogram.
qsort-def.h is a metaprogram to define specialized instances of the quick-sort algorithm.
qsort-def.h is used to define a specialization of the ::VL_QSORT_sort function that operates on a given type of array. For instance the code
#define VL_QSORT_type float #define VL_QSORT_prefix my_qsort #include <vl/qsort-def.h>
defines a function my_qsort_sort
that operates on an array of floats.
Definition in file qsort-def.h.
#define VL_QSORT_array VL_QSORT_type* |
Definition at line 49 of file qsort-def.h.
#define VL_QSORT_array_const VL_QSORT_type const* |
Definition at line 50 of file qsort-def.h.
#define VL_QSORT_cmp VL_XCAT(VL_QSORT_prefix, _cmp) |
Definition at line 62 of file qsort-def.h.
#define VL_QSORT_swap VL_XCAT(VL_QSORT_prefix, _swap) |
Definition at line 87 of file qsort-def.h.
VL_INLINE VL_QSORT_type VL_QSORT_cmp | ( | VL_QSORT_array_const | array, |
vl_uindex | indexA, | ||
vl_uindex | indexB | ||
) |
Compare two array elements.
array | qsort array. |
indexA | index of the first element A to compare. |
indexB | index of the second element B to comapre. |
A<B
, 0 if A==B
, and a positive number if if A>B
. Definition at line 74 of file qsort-def.h.
VL_INLINE void VL_QSORT_swap | ( | VL_QSORT_array | array, |
vl_uindex | indexA, | ||
vl_uindex | indexB | ||
) |
Swap two array elements.
array | qsort array. |
indexA | index of the first element to swap. |
indexB | index of the second element to swap. |
The function swaps the two elements a and @ b. The function uses a temporary element of type VL_QSORT_type and the copy operator =
.
Definition at line 101 of file qsort-def.h.