sortautarray - heap sort.
This software belongs to the ALLIANCE CAD system from the CAO-VLSI team at
ASIM/LIP6/UPMC laboratory.
LIP6/ASIM
University P. et M. Curie
4, place Jussieu
75252 PARIS Cedex 05
FRANCE
Fax : {33/0} 1.44.27.62.86
E-mail support : alliance-support@asim.lip6.fr
#include aut101.h"
void sortautarray( ValueArray, IndexArray, ArraySize, FuncCompare )
void *ValueArray;
long *IndexArray;
long ArraySize;
long (*FuncCompare)();
sortautarray is an implementation of the heap-sort algorithm. It sorts an array of values pointed by ValueArray, and saves the values order in the array of indexes pointed by IndexArray. The comparison function is called with three arguments. The First is a pointer to the array of values, the second one and the last one is respectively the index of the first and second value being compared. If FuncCompare is a null pointer, a default comparison function is used and sort ValueArray in decrease order. Val_ueArray is not modified by this function, and this seems to be usefull in many cases. A the end IndexArray contains the indexes of the sorted values.
sortautarray returns nothing.
#include aut101.h"
long SortCompare( ValueArray, Index1, Index2 )
long *ValueArray;
long Index1;
long Index2;
{
return( ValueArray[ Index2 ] - ValueArray[ Index1 ] );
}
...
long ValueArray[ 5 ] = { 3, 2, 1, 5, 4 };
long IndexArray[ 5 ];
sortautarray( ValueArray, IndexArray, 5, NULL );
/* display 5 4 3 2 1 */
for ( Counter = 0; Counter < 5; Counter++ )
{
printf( %d", ValueArray[ IndexArray[ Counter ] ] );
}
printf( 0 );
sortautarray( ValueArray, IndexArray, SortCompare );
/* display 1 2 3 4 5 */
for ( Counter = 0; Counter < 5; Counter++ )
{
printf( %d", ValueArray[ IndexArray[ Counter ] ] );
}
printf( 0 );
This tool is under development at the ASIM/LIP6/UPMC laboratory, cao-vlsi
research team.
We need your feedbak to improve documentation and tools.
If you find bugs, please fill-in the form at
http://asim.lip6.fr/alliance/support/bug-report/
Thanks for doing this.