diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2015-08-09 22:46:40 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2015-08-09 22:46:40 -0700 |
commit | a14e2c921fea9a603c4ea7e718958cca7d9b3e94 (patch) | |
tree | 62fa4411a3b48f5a08d0899a41783c99f7e7eb4e /src/misc/vec | |
parent | 8a30b675b5e93db1c63353b72820c95198d5dc4b (diff) | |
download | abc-a14e2c921fea9a603c4ea7e718958cca7d9b3e94.tar.gz abc-a14e2c921fea9a603c4ea7e718958cca7d9b3e94.tar.bz2 abc-a14e2c921fea9a603c4ea7e718958cca7d9b3e94.zip |
Improvements to Cba data-structure.
Diffstat (limited to 'src/misc/vec')
-rw-r--r-- | src/misc/vec/vecInt.h | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/misc/vec/vecInt.h b/src/misc/vec/vecInt.h index 2487911a..785b0aef 100644 --- a/src/misc/vec/vecInt.h +++ b/src/misc/vec/vecInt.h @@ -728,6 +728,19 @@ static inline void Vec_IntPushTwo( Vec_Int_t * p, int Entry1, int Entry2 ) Vec_IntPush( p, Entry1 ); Vec_IntPush( p, Entry2 ); } +static inline void Vec_IntPushThree( Vec_Int_t * p, int Entry1, int Entry2, int Entry3 ) +{ + Vec_IntPush( p, Entry1 ); + Vec_IntPush( p, Entry2 ); + Vec_IntPush( p, Entry3 ); +} +static inline void Vec_IntPushFour( Vec_Int_t * p, int Entry1, int Entry2, int Entry3, int Entry4 ) +{ + Vec_IntPush( p, Entry1 ); + Vec_IntPush( p, Entry2 ); + Vec_IntPush( p, Entry3 ); + Vec_IntPush( p, Entry4 ); +} static inline void Vec_IntPushArray( Vec_Int_t * p, int * pEntries, int nEntries ) { int i; @@ -1338,14 +1351,14 @@ 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 ) +static inline void Vec_IntSortMulti( Vec_Int_t * p, int nMulti, int fReverse ) { - assert( Vec_IntSize(p) % 2 == 0 ); + assert( Vec_IntSize(p) % nMulti == 0 ); if ( fReverse ) - qsort( (void *)p->pArray, p->nSize/2, 2*sizeof(int), + qsort( (void *)p->pArray, p->nSize/nMulti, nMulti*sizeof(int), (int (*)(const void *, const void *)) Vec_IntSortCompare2 ); else - qsort( (void *)p->pArray, p->nSize/2, 2*sizeof(int), + qsort( (void *)p->pArray, p->nSize/nMulti, nMulti*sizeof(int), (int (*)(const void *, const void *)) Vec_IntSortCompare1 ); } @@ -1419,7 +1432,7 @@ static inline int Vec_IntUniqifyPairs( Vec_Int_t * p ) assert( p->nSize % 2 == 0 ); if ( p->nSize < 4 ) return 0; - Vec_IntSortPairs( p, 0 ); + Vec_IntSortMulti( p, 2, 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] ) { |