|
Linux Kernel
3.7.1
|
Go to the source code of this file.
Functions | |
| void | sort (void *base, size_t num, size_t size, int(*cmp_func)(const void *, const void *), void(*swap_func)(void *, void *, int size)) |
| EXPORT_SYMBOL (sort) | |
| EXPORT_SYMBOL | ( | sort | ) |
| void sort | ( | void * | base, |
| size_t | num, | ||
| size_t | size, | ||
| int(*)(const void *, const void *) | cmp_func, | ||
| void(*)(void *, void *, int size) | swap_func | ||
| ) |
sort - sort an array of elements : pointer to data to sort : number of elements : size of each element : pointer to comparison function : pointer to swap function or NULL
This function does a heapsort on the given array. You may provide a swap_func function optimized to your element type.
Sorting time is O(n log n) both on average and worst-case. While qsort is about 20% faster on average, it suffers from exploitable O(n*n) worst-case behavior and extra memory requirements that make it less suitable for kernel use.
1.8.2