Implements an Iterative Quicksort Algorithm for the SigV4 Library. More...
Macros | |
#define | PUSH_STACK(valueToPush, stack, index) |
Push a value to the stack. | |
#define | POP_STACK(valueToPop, stack, index) |
Pop a value from the stack. | |
Functions | |
static void | swap (void *pFirstItem, void *pSecondItem, size_t itemSize) |
A helper function to swap the value of two pointers given their sizes. | |
static void | quickSortHelper (void *pArray, size_t low, size_t high, size_t itemSize, ComparisonFunc_t comparator) |
A helper function to perform quicksort on a subarray. | |
static size_t | partition (void *pArray, size_t low, size_t high, size_t itemSize, ComparisonFunc_t comparator) |
A helper function to partition a subarray using the last element of the array as the pivot. All items smaller than the pivot end up at its left while all items greater than end up at its right. | |
void | quickSort (void *pArray, size_t numItems, size_t itemSize, ComparisonFunc_t comparator) |
Perform quicksort on an array. | |
Implements an Iterative Quicksort Algorithm for the SigV4 Library.
#define PUSH_STACK | ( | valueToPush, | |
stack, | |||
index | |||
) |
Push a value to the stack.
#define POP_STACK | ( | valueToPop, | |
stack, | |||
index | |||
) |
Pop a value from the stack.
|
static |
A helper function to swap the value of two pointers given their sizes.
[in] | pFirstItem | The item to swap with pSecondItem . |
[in] | pSecondItem | The item to swap with pFirstItem . |
[in] | itemSize | The amount of memory per entry in the array. |
|
static |
A helper function to perform quicksort on a subarray.
[in] | pArray | The array to be sorted. |
[in] | low | The low index of the array. |
[in] | high | The high index of the array. |
[in] | itemSize | The amount of memory per entry in the array. |
[out] | comparator | The comparison function to determine if one item is less than another. |
|
static |
A helper function to partition a subarray using the last element of the array as the pivot. All items smaller than the pivot end up at its left while all items greater than end up at its right.
[in] | pArray | The array to be sorted. |
[in] | low | The low index of the array. |
[in] | high | The high index of the array. |
[in] | itemSize | The amount of memory per entry in the array. |
[out] | comparator | The comparison function to determine if one item is less than another. |
void quickSort | ( | void * | pArray, |
size_t | numItems, | ||
size_t | itemSize, | ||
ComparisonFunc_t | comparator | ||
) |
Perform quicksort on an array.
[in] | pArray | The array to be sorted. |
[in] | numItems | The number of items in an array. |
[in] | itemSize | The amount of memory per entry in the array. |
[out] | comparator | The comparison function to determine if one item is less than another. |