MATH_QSort

C Specification

#include <nitro/math/qsort.h>

void MATH_QSort( void *head,
u32 num,
u32 width,
MATHCompareFunc comp, 
void *stackBuf );

Arguments

head Pointer to the data to sort.
num The number of pieces of data to sort.
width The size of each piece of data.
comp Comparison function for the elements in the array.
stackBuf Provides a buffer to be used interally. You can obtain the required buffer size with MATH_QSortStackSize.
If this argument is NULL, memory will be allocated from the stack. Be alert to the possiblity of stack overflow.

Return Values

None.

Description

This function performs a quicksort.
The function does not use a recursive call. Instead, the stackBuf argument must be used to provide a work area for the sort.
If the work area is provided by NULL, the stack will be used for the sort. Be aware of the possiblity of stack overflow.
The required size of the work area is (Log2(num)+1) * 8 bytes. You can obtain this value with MATH_QSortStackSize.

See Also

MATHCompareFunc, MATH_QSortStackSize

Revision History

04/12/2005 Initial version.