VPR-6.0

vpr/SRC/util/heapsort.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void heapsort (int *sort_index, float *sort_values, int nelem, int start_index)

Function Documentation

void heapsort ( int *  sort_index,
float *  sort_values,
int  nelem,
int  start_index 
)

This routine loads sort_index [1..nelem] with nelem values: the indices of the sort_values [1..nelem] array that lead to sort_values[index] being decreasing as one goes through sort_index. Sort_values is not changed.

Definition at line 23 of file heapsort.c.

{

    int i;

        sort_index-=start_index;
        sort_values-=start_index;

/* Build a heap with the *smallest* element at the top. */

    for(i = 1; i <= nelem; i++)
        add_to_sort_heap(sort_index, sort_values, i, i);

/* Now pull items off the heap, smallest first.  As the heap (in sort_index) *
 * shrinks, I store the item pulled off (the smallest) in sort_index,        *
 * starting from the end. The heap and the stored smallest values never      *
 * overlap, so I get a nice sort-in-place.                                   */

    for(i = nelem; i >= 1; i--)
        sort_index[i] = get_top_of_heap_index(sort_index, sort_values, i, start_index);

        sort_index+=start_index;
        sort_values+=start_index;
}

Here is the call graph for this function:

Here is the caller graph for this function: