From d5955db9604a2eb9224941b5200648120b22fc82 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 31 Jul 2011 20:20:10 +0700 Subject: Added new APIs to integer vector. --- src/misc/vec/vecInt.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src/misc/vec/vecInt.h') 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 /// @@ -904,6 +906,44 @@ static inline int Vec_IntSum( Vec_Int_t * p ) return Counter; } +/**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.] -- cgit v1.2.3