QSort preprocessor metaprogram. More...
Macros | |
#define | VL_QSORT_array VL_QSORT_type* |
#define | VL_QSORT_prefix QSortPrefix |
#define | VL_QSORT_type QSortType |
#define | VL_QSORT_array QSortType* |
Functions | |
VL_QSORT_type | VL_QSORT_cmp (VL_QSORT_array_const array, vl_uindex indexA, vl_uindex indexB) |
Compare two array elements. More... | |
void | VL_QSORT_swap (VL_QSORT_array array, vl_uindex indexA, vl_uindex indexB) |
Swap two array elements. More... | |
void | VL_QSORT_sort_recursive (VL_QSORT_array array, vl_uindex begin, vl_uindex end) |
Sort portion of an array using quicksort. More... | |
void | VL_QSORT_sort (VL_QSORT_array array, vl_size size) |
Sort array using quicksort. More... | |
Detailed Description
Overview
qsort-def.h is a metaprogram to define specialized instances of the quick-sort algorithm.
Usage
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.
- Todo:
- large array compatibility.
Macro Definition Documentation
◆ VL_QSORT_array [1/2]
#define VL_QSORT_array VL_QSORT_type* |
Data type of the qsort container
◆ VL_QSORT_array [2/2]
#define VL_QSORT_array QSortType* |
Data type of the qsort container
◆ VL_QSORT_prefix
#define VL_QSORT_prefix QSortPrefix |
Prefix of the qsort functions
◆ VL_QSORT_type
#define VL_QSORT_type QSortType |
Data type of the qsort elements
Function Documentation
◆ VL_QSORT_cmp()
|
inline |
- Parameters
-
array qsort array. indexA index of the first element A
to compare.indexB index of the second element B
to comapre.
- Returns
- a negative number if
A<B
, 0 ifA==B
, and a positive number if ifA>B
.
◆ VL_QSORT_sort()
|
inline |
- Parameters
-
array (in/out) pointer to the array. size size of the array.
The function sorts the array using quick-sort.
◆ VL_QSORT_sort_recursive()
|
inline |
- Parameters
-
array (in/out) pointer to the array. begin first element of the array portion. end last element of the array portion.
The function sorts the array using quick-sort. Note that begin
must be not larger than end
.
◆ VL_QSORT_swap()
|
inline |
- Parameters
-
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 =
.