diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2014-06-26 09:51:53 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2014-06-26 09:51:53 -0700 |
commit | a68ec38df1cbe557a46d53cf28bbe74a00bc979a (patch) | |
tree | 57c4dd063b078d355df8a55ba62780157cf896d2 /src/misc/vec | |
parent | 2edf2a970ee3663ef0725f22972a10083ed81fbf (diff) | |
download | abc-a68ec38df1cbe557a46d53cf28bbe74a00bc979a.tar.gz abc-a68ec38df1cbe557a46d53cf28bbe74a00bc979a.tar.bz2 abc-a68ec38df1cbe557a46d53cf28bbe74a00bc979a.zip |
Changes and improvements to different packages.
Diffstat (limited to 'src/misc/vec')
-rw-r--r-- | src/misc/vec/vecInt.h | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/misc/vec/vecInt.h b/src/misc/vec/vecInt.h index 535a15ef..6d015bcc 100644 --- a/src/misc/vec/vecInt.h +++ b/src/misc/vec/vecInt.h @@ -1715,16 +1715,27 @@ static inline void Vec_IntSelectSort( int * pArray, int nSize ) ***********************************************************************/ static inline void Vec_IntSelectSortCost( int * pArray, int nSize, Vec_Int_t * vCosts ) { - int temp, i, j, best_i; + int i, j, best_i; for ( i = 0; i < nSize-1; i++ ) { best_i = i; for ( j = i+1; j < nSize; j++ ) if ( Vec_IntEntry(vCosts, pArray[j]) < Vec_IntEntry(vCosts, pArray[best_i]) ) best_i = j; - temp = pArray[i]; - pArray[i] = pArray[best_i]; - pArray[best_i] = temp; + ABC_SWAP( int, pArray[i], pArray[best_i] ); + } +} +static inline void Vec_IntSelectSortCost2( int * pArray, int nSize, int * pCosts ) +{ + int i, j, best_i; + for ( i = 0; i < nSize-1; i++ ) + { + best_i = i; + for ( j = i+1; j < nSize; j++ ) + if ( pCosts[j] < pCosts[best_i] ) + best_i = j; + ABC_SWAP( int, pArray[i], pArray[best_i] ); + ABC_SWAP( int, pCosts[i], pCosts[best_i] ); } } |