Implements an Iterative Quicksort Algorithm for the SigV4 Client Utility Library. More...
Macros | |
#define | PUSH_STACK(valueToPush, stack, index) |
Push a value to the stack. More... | |
#define | POP_STACK(valueToPop, stack, index) |
Pop a value from the stack. More... | |
Functions | |
static void | swap (void *pFirstItem, void *pSecondItem, size_t itemSize) |
A helper function to swap the value of two pointers given their sizes. More... | |
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. More... | |
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. More... | |
void | quickSort (void *pArray, size_t numItems, size_t itemSize, ComparisonFunc_t comparator) |
Perform quicksort on an array. More... | |
Implements an Iterative Quicksort Algorithm for the SigV4 Client Utility 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. |