SRC/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)

Function Documentation

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

Definition at line 19 of file heapsort.c.

00022 {
00023 
00024 /* This routine loads sort_index [1..nelem] with nelem values:  the indices  *
00025  * of the sort_values [1..nelem] array that lead to sort_values[index] being *
00026  * decreasing as one goes through sort_index.  Sort_values is not changed.   */
00027 
00028     int i;
00029 
00030 /* Build a heap with the *smallest* element at the top. */
00031 
00032     for(i = 1; i <= nelem; i++)
00033         add_to_sort_heap(sort_index, sort_values, i, i);
00034 
00035 /* Now pull items off the heap, smallest first.  As the heap (in sort_index) *
00036  * shrinks, I store the item pulled off (the smallest) in sort_index,        *
00037  * starting from the end. The heap and the stored smallest values never      *
00038  * overlap, so I get a nice sort-in-place.                                   */
00039 
00040     for(i = nelem; i >= 1; i--)
00041         sort_index[i] = get_top_of_heap_index(sort_index, sort_values, i);
00042 }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Tue Jan 5 15:25:47 2010 for VPR5.0 by  doxygen 1.6.1