Fix heapsort, add test

This commit is contained in:
Nils O. Selåsdal
2013-12-03 11:30:09 +01:00
parent a5662a2edd
commit 70fb352656
4 changed files with 130 additions and 16 deletions
+13 -4
View File
@@ -8,11 +8,20 @@ extern "C" {
#endif
///compare function. Needs only to return < 0 if
//the first element is less than the second
typedef int (*uc_hs_cmp)(const void *, const void *);
typedef int (*uc_hs_cmp)(const void *, const void *, void *cookie);
//swap function
typedef void (*uc_hs_swp)(void *, void *);
void
uc_heapsort(void *base, size_t count, size_t width,
uc_hs_cmp cmp);
/** Sort an array.
* @param base start of array
* @param count number of elements in array
* @param width size of each element
* @param cmp compare function
* @param swap swap function
* @param cookie user pointer passed back to compare function
*/
void uc_heapsort(void *base, size_t count, size_t width,
uc_hs_cmp cmp, uc_hs_swp swap, void *cookie);
#ifdef __cplusplus
}