diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2011-07-31 20:20:10 +0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2011-07-31 20:20:10 +0700 |
commit | d5955db9604a2eb9224941b5200648120b22fc82 (patch) | |
tree | fcce24b01f39fc486334e95e30d31427222a5297 /src/misc | |
parent | 5303465ed6966d93559add04dceace1f4600b32b (diff) | |
download | abc-d5955db9604a2eb9224941b5200648120b22fc82.tar.gz abc-d5955db9604a2eb9224941b5200648120b22fc82.tar.bz2 abc-d5955db9604a2eb9224941b5200648120b22fc82.zip |
Added new APIs to integer vector.
Diffstat (limited to 'src/misc')
-rw-r--r-- | src/misc/vec/vecInt.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/misc/vec/vecInt.h b/src/misc/vec/vecInt.h index d222bafd..04f41b5b 100644 --- a/src/misc/vec/vecInt.h +++ b/src/misc/vec/vecInt.h @@ -63,6 +63,8 @@ struct Vec_Int_t_ for ( i = Vec_IntSize(vVec) - 1; (i >= 0) && (((pEntry) = Vec_IntEntry(vVec, i)), 1); i-- ) #define Vec_IntForEachEntryTwo( vVec1, vVec2, Entry1, Entry2, i ) \ for ( i = 0; (i < Vec_IntSize(vVec1)) && (((Entry1) = Vec_IntEntry(vVec1, i)), 1) && (((Entry2) = Vec_IntEntry(vVec2, i)), 1); i++ ) +#define Vec_IntForEachEntryDouble( vVec, Entry1, Entry2, i ) \ + for ( i = 0; (2*i+1 < Vec_IntSize(vVec)) && (((Entry1) = Vec_IntEntry(vVec, 2*i)), 1) && (((Entry2) = Vec_IntEntry(vVec, 2*i+1)), 1); i += 2 ) //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// @@ -906,6 +908,44 @@ static inline int Vec_IntSum( Vec_Int_t * p ) /**Function************************************************************* + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Vec_IntCountZero( Vec_Int_t * p ) +{ + int i, Counter = 0; + for ( i = 0; i < p->nSize; i++ ) + Counter += (p->pArray[i] == 0); + return Counter; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Vec_IntCountPositive( Vec_Int_t * p ) +{ + int i, Counter = 0; + for ( i = 0; i < p->nSize; i++ ) + Counter += (p->pArray[i] > 0); + return Counter; +} + +/**Function************************************************************* + Synopsis [Counts the number of common entries.] Description [Assumes that the entries are non-negative integers that |