13 void heapsort(
int *sort_index,
float *sort_values,
int nelem,
int start_index) {
21 sort_index -= start_index;
22 sort_values -= start_index;
26 for (i = 1; i <= nelem; i++)
34 for (i = nelem; i >= 1; i--)
38 sort_index += start_index;
39 sort_values += start_index;
48 unsigned int ifrom, ito;
55 while (ito >= 1 && sort_values[heap[ifrom]] < sort_values[heap[ito]]) {
57 heap[ito] = heap[ifrom];
71 int index_of_smallest, temp;
72 unsigned int ifrom, ito, heap_end;
74 index_of_smallest = heap[1];
76 heap_end = heap_tail - 1;
80 while (ito <= heap_end) {
81 if (sort_values[heap[ito + 1]] < sort_values[heap[ito]])
84 if (sort_values[heap[ito]] > sort_values[heap[ifrom]])
88 heap[ito] = heap[ifrom];
95 return (index_of_smallest - start_index);
void heapsort(int *sort_index, float *sort_values, int nelem, int start_index)
static void add_to_sort_heap(int *heap, float *sort_values, int index, int heap_tail)
static struct s_heap ** heap
static int get_top_of_heap_index(int *heap, float *sort_values, int heap_tail, int start_index)