diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2015-03-23 18:40:38 +0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2015-03-23 18:40:38 +0700 |
commit | efdd26f86d3dbbde1626fe6a84304bc700b97479 (patch) | |
tree | da4ebd027e5e8de8a03a4a0cb15fa72a31d2ca74 /src/misc/vec/vecInt.h | |
parent | 5f77e7ae8fb6ed29812aa67514109d961a61c112 (diff) | |
download | abc-efdd26f86d3dbbde1626fe6a84304bc700b97479.tar.gz abc-efdd26f86d3dbbde1626fe6a84304bc700b97479.tar.bz2 abc-efdd26f86d3dbbde1626fe6a84304bc700b97479.zip |
Scalable SOP manipulation package.
Diffstat (limited to 'src/misc/vec/vecInt.h')
-rw-r--r-- | src/misc/vec/vecInt.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/misc/vec/vecInt.h b/src/misc/vec/vecInt.h index 6d3ea8f6..e18b4616 100644 --- a/src/misc/vec/vecInt.h +++ b/src/misc/vec/vecInt.h @@ -1338,6 +1338,16 @@ static inline void Vec_IntSort( Vec_Int_t * p, int fReverse ) qsort( (void *)p->pArray, p->nSize, sizeof(int), (int (*)(const void *, const void *)) Vec_IntSortCompare1 ); } +static inline void Vec_IntSortPairs( Vec_Int_t * p, int fReverse ) +{ + assert( Vec_IntSize(p) % 2 == 0 ); + if ( fReverse ) + qsort( (void *)p->pArray, p->nSize/2, 2*sizeof(int), + (int (*)(const void *, const void *)) Vec_IntSortCompare2 ); + else + qsort( (void *)p->pArray, p->nSize/2, 2*sizeof(int), + (int (*)(const void *, const void *)) Vec_IntSortCompare1 ); +} /**Function************************************************************* @@ -1394,6 +1404,36 @@ static inline int Vec_IntCountUnique( Vec_Int_t * p ) /**Function************************************************************* + Synopsis [Counts the number of unique pairs.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Vec_IntUniqifyPairs( Vec_Int_t * p ) +{ + int i, k, RetValue; + assert( p->nSize % 2 == 0 ); + if ( p->nSize < 4 ) + return 0; + Vec_IntSortPairs( p, 0 ); + for ( i = k = 1; i < p->nSize/2; i++ ) + if ( p->pArray[2*i] != p->pArray[2*(i-1)] || p->pArray[2*i+1] != p->pArray[2*(i-1)+1] ) + { + p->pArray[2*k] = p->pArray[2*i]; + p->pArray[2*k+1] = p->pArray[2*i+1]; + k++; + } + RetValue = p->nSize/2 - k; + p->nSize = 2*k; + return RetValue; +} + +/**Function************************************************************* + Synopsis [Counts the number of unique entries.] Description [] @@ -1891,6 +1931,13 @@ static inline void Vec_IntAppend( Vec_Int_t * vVec1, Vec_Int_t * vVec2 ) Vec_IntForEachEntry( vVec2, Entry, i ) Vec_IntPush( vVec1, Entry ); } +static inline void Vec_IntAppendSkip( Vec_Int_t * vVec1, Vec_Int_t * vVec2, int iVar ) +{ + int Entry, i; + Vec_IntForEachEntry( vVec2, Entry, i ) + if ( i != iVar ) + Vec_IntPush( vVec1, Entry ); +} ABC_NAMESPACE_HEADER_END |