Table of Contents

Name

sortautarray - heap sort.

Origin

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

Synopsys

#include aut101.h"
void sortautarray( ValueArray, IndexArray, ArraySize, FuncCompare ) void *ValueArray;
long *IndexArray;
long ArraySize;
long (*FuncCompare)();

Parameters

ValueArray
Array of values to be compared.
IndexArray
Array of indexes.
ArraySize
Size of the arrays.
FuncCompare
The name of the comparison function.

Description

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.

Return Value

sortautarray returns nothing.

Example

#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 );

See Also

aut(1)

Bug Report

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.


Table of Contents

 



Alliance Web Site © 1997, 2002 ASIM/LIP6/UPMC, page maintained by Czo [Olivier Sirol] , last updated on 26 May 2000.