First bit of ex35
This commit is contained in:
19
lcthw-remnants-2/liblcthw/src/lcthw/darray_algos.c
Normal file
19
lcthw-remnants-2/liblcthw/src/lcthw/darray_algos.c
Normal 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);
|
||||
}
|
14
lcthw-remnants-2/liblcthw/src/lcthw/darray_algos.h
Normal file
14
lcthw-remnants-2/liblcthw/src/lcthw/darray_algos.h
Normal 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
|
Reference in New Issue
Block a user