First bit of ex35

This commit is contained in:
Dan Buch
2016-04-18 09:42:33 -04:00
parent 64dfc0cb6f
commit fcf1c92608
4 changed files with 112 additions and 1 deletions

View File

@@ -0,0 +1,19 @@
#include <lcthw/darray_algos.h>
#include <stdlib.h>
#include <bsd/stdlib.h>
int DArray_qsort(DArray *array, DArray_compare cmp)
{
qsort(array->contents, DArray_count(array), sizeof(void *), cmp);
return 0;
}
int DArray_heapsort(DArray *array, DArray_compare cmp)
{
return heapsort(array->contents, DArray_count(array), sizeof(void *), cmp);
}
int DArray_mergesort(DArray *array, DArray_compare cmp)
{
return mergesort(array->contents, DArray_count(array), sizeof(void *), cmp);
}

View File

@@ -0,0 +1,14 @@
#ifndef lcthw_DArray_algos_h
#define lcthw_DArray_algos_h
#include <lcthw/darray.h>
typedef int (*DArray_compare)(const void *a, const void *b);
int DArray_qsort(DArray *array, DArray_compare cmp);
int DArray_heapsort(DArray *array, DArray_compare cmp);
int DArray_mergesort(DArray *array, DArray_compare cmp);
#endif