diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2013-10-06 15:57:17 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2013-10-06 15:57:17 -0700 |
commit | 8a03e530c299fba1e862a5943207c39fbd52ee06 (patch) | |
tree | 775a402f266cd507849d188b0f6db0b76250be86 /src/misc | |
parent | 812a877ab694956be34b979fbd219a244580cced (diff) | |
download | abc-8a03e530c299fba1e862a5943207c39fbd52ee06.tar.gz abc-8a03e530c299fba1e862a5943207c39fbd52ee06.tar.bz2 abc-8a03e530c299fba1e862a5943207c39fbd52ee06.zip |
Resubstitution code.
Diffstat (limited to 'src/misc')
-rw-r--r-- | src/misc/vec/vecInt.h | 13 | ||||
-rw-r--r-- | src/misc/vec/vecWec.h | 50 |
2 files changed, 43 insertions, 20 deletions
diff --git a/src/misc/vec/vecInt.h b/src/misc/vec/vecInt.h index 5456dc0b..f8dc9385 100644 --- a/src/misc/vec/vecInt.h +++ b/src/misc/vec/vecInt.h @@ -1473,9 +1473,8 @@ static inline int Vec_IntTwoRemove( Vec_Int_t * vArr1, Vec_Int_t * vArr2 ) SeeAlso [] ***********************************************************************/ -static inline Vec_Int_t * Vec_IntTwoMerge( Vec_Int_t * vArr1, Vec_Int_t * vArr2 ) +static inline void Vec_IntTwoMerge2Int( Vec_Int_t * vArr1, Vec_Int_t * vArr2, Vec_Int_t * vArr ) { - Vec_Int_t * vArr = Vec_IntAlloc( vArr1->nSize + vArr2->nSize ); int * pBeg = vArr->pArray; int * pBeg1 = vArr1->pArray; int * pBeg2 = vArr2->pArray; @@ -1498,8 +1497,18 @@ static inline Vec_Int_t * Vec_IntTwoMerge( Vec_Int_t * vArr1, Vec_Int_t * vArr2 assert( vArr->nSize <= vArr->nCap ); assert( vArr->nSize >= vArr1->nSize ); assert( vArr->nSize >= vArr2->nSize ); +} +static inline Vec_Int_t * Vec_IntTwoMerge( Vec_Int_t * vArr1, Vec_Int_t * vArr2 ) +{ + Vec_Int_t * vArr = Vec_IntAlloc( vArr1->nSize + vArr2->nSize ); + Vec_IntTwoMerge2Int( vArr1, vArr2, vArr ); return vArr; } +static inline void Vec_IntTwoMerge2( Vec_Int_t * vArr1, Vec_Int_t * vArr2, Vec_Int_t * vArr ) +{ + Vec_IntGrow( vArr, Vec_IntSize(vArr1) + Vec_IntSize(vArr2) ); + Vec_IntTwoMerge2Int( vArr1, vArr2, vArr ); +} /**Function************************************************************* diff --git a/src/misc/vec/vecWec.h b/src/misc/vec/vecWec.h index cd4910b3..f2fe3216 100644 --- a/src/misc/vec/vecWec.h +++ b/src/misc/vec/vecWec.h @@ -399,7 +399,7 @@ static inline Vec_Wec_t * Vec_WecDup( Vec_Wec_t * p ) /**Function************************************************************* - Synopsis [Comparison procedure for two arrays.] + Synopsis [Sorting by array size.] Description [] @@ -424,18 +424,6 @@ static int Vec_WecSortCompare2( Vec_Int_t * p1, Vec_Int_t * p2 ) return 1; return 0; } - -/**Function************************************************************* - - Synopsis [Sorting the entries by their integer value.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ static inline void Vec_WecSort( Vec_Wec_t * p, int fReverse ) { if ( fReverse ) @@ -446,9 +434,10 @@ static inline void Vec_WecSort( Vec_Wec_t * p, int fReverse ) (int (*)(const void *, const void *)) Vec_WecSortCompare1 ); } + /**Function************************************************************* - Synopsis [Comparison procedure for two integers.] + Synopsis [Sorting by the first entry.] Description [] @@ -473,10 +462,19 @@ static int Vec_WecSortCompare4( Vec_Int_t * p1, Vec_Int_t * p2 ) return 1; return 0; } +static inline void Vec_WecSortByFirstInt( Vec_Wec_t * p, int fReverse ) +{ + if ( fReverse ) + qsort( (void *)p->pArray, p->nSize, sizeof(Vec_Int_t), + (int (*)(const void *, const void *)) Vec_WecSortCompare4 ); + else + qsort( (void *)p->pArray, p->nSize, sizeof(Vec_Int_t), + (int (*)(const void *, const void *)) Vec_WecSortCompare3 ); +} /**Function************************************************************* - Synopsis [Sorting the entries by their integer value.] + Synopsis [Sorting by the last entry.] Description [] @@ -485,14 +483,30 @@ static int Vec_WecSortCompare4( Vec_Int_t * p1, Vec_Int_t * p2 ) SeeAlso [] ***********************************************************************/ -static inline void Vec_WecSortByFirstInt( Vec_Wec_t * p, int fReverse ) +static int Vec_WecSortCompare5( Vec_Int_t * p1, Vec_Int_t * p2 ) +{ + if ( Vec_IntEntryLast(p1) < Vec_IntEntryLast(p2) ) + return -1; + if ( Vec_IntEntryLast(p1) > Vec_IntEntryLast(p2) ) + return 1; + return 0; +} +static int Vec_WecSortCompare6( Vec_Int_t * p1, Vec_Int_t * p2 ) +{ + if ( Vec_IntEntryLast(p1) > Vec_IntEntryLast(p2) ) + return -1; + if ( Vec_IntEntryLast(p1) < Vec_IntEntryLast(p2) ) + return 1; + return 0; +} +static inline void Vec_WecSortByLastInt( Vec_Wec_t * p, int fReverse ) { if ( fReverse ) qsort( (void *)p->pArray, p->nSize, sizeof(Vec_Int_t), - (int (*)(const void *, const void *)) Vec_WecSortCompare4 ); + (int (*)(const void *, const void *)) Vec_WecSortCompare6 ); else qsort( (void *)p->pArray, p->nSize, sizeof(Vec_Int_t), - (int (*)(const void *, const void *)) Vec_WecSortCompare3 ); + (int (*)(const void *, const void *)) Vec_WecSortCompare5 ); } /**Function************************************************************* |