* ASORT_KEY_TYPE [*] data type of a single array entry key
* ASORT_ELT(i) returns the key of i-th element; if this macro is not
* defined, the function gets a pointer to an array to be sorted
- * ASORT_LT(x,y) x < y for ASORT_TYPE (default: "x<y")
+ * ASORT_LT(x,y) x < y for ASORT_KEY_TYPE (default: "x<y")
* ASORT_SWAP(i,j) swap i-th and j-th element (default: assume _ELT
* is an l-value and swap just the keys)
* ASORT_THRESHOLD threshold for switching between quicksort and insertsort
* ASORT_EXTRA_ARGS extra arguments for the sort function (they are always
* visible in all the macros supplied above), starts with comma
*
- * After including this file, a function ASORT_PREFIX(sort)(uns array_size)
- * or ASORT_PREFIX(sort)(ASORT_KEY_TYPE *array, uns array_size) [if ASORT_ELT
+ * After including this file, a function ASORT_PREFIX(sort)(uint array_size)
+ * or ASORT_PREFIX(sort)(ASORT_KEY_TYPE *array, uint array_size) [if ASORT_ELT
* is not defined] is declared and all parameter macros are automatically
* undef'd.
*/
#endif
#ifndef ASORT_ELT
-#define ASORT_ARRAY_ARG
+#define ASORT_ARRAY_ARG ASORT_KEY_TYPE *array,
#define ASORT_ELT(i) array[i]
+#else
+#define ASORT_ARRAY_ARG
#endif
-static void ASORT_PREFIX(sort)(
-#ifdef ASORT_ARRAY_ARG
- ASORT_KEY_TYPE *array,
-#endif
- uns array_size ASORT_EXTRA_ARGS)
+/**
+ * The generated sorting function. If `ASORT_ELT` macro is not provided, the
+ * @ASORT_ARRAY_ARG is equal to `ASORT_KEY_TYPE *array` and is the array to be
+ * sorted. If the macro is provided, this parameter is omitted. In that case,
+ * you can sort global variables or pass your structure by @ASORT_EXTRA_ARGS.
+ **/
+static void ASORT_PREFIX(sort)(ASORT_ARRAY_ARG uint array_size ASORT_EXTRA_ARGS)
{
- struct stk { int l, r; } stack[8*sizeof(uns)];
+ struct stk { int l, r; } stack[8*sizeof(uint)];
int l, r, left, right, m;
- uns sp = 0;
+ uint sp = 0;
ASORT_KEY_TYPE pivot;
if (array_size <= 1)