summaryrefslogtreecommitdiffstats
path: root/src/misc/vec/vecInt.h
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2007-04-08 08:01:00 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2007-04-08 08:01:00 -0700
commitc09d4d499cee70f02e3e9a18226554b8d1d34488 (patch)
tree89ac20b1029dc8407f655224f6ef2b5f431fa453 /src/misc/vec/vecInt.h
parent94112fd22fc6f09ccc488cfc577d43aebeff9c5f (diff)
downloadabc-c09d4d499cee70f02e3e9a18226554b8d1d34488.tar.gz
abc-c09d4d499cee70f02e3e9a18226554b8d1d34488.tar.bz2
abc-c09d4d499cee70f02e3e9a18226554b8d1d34488.zip
Version abc70408
Diffstat (limited to 'src/misc/vec/vecInt.h')
-rw-r--r--src/misc/vec/vecInt.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/misc/vec/vecInt.h b/src/misc/vec/vecInt.h
index 75693895..f992c3cc 100644
--- a/src/misc/vec/vecInt.h
+++ b/src/misc/vec/vecInt.h
@@ -775,6 +775,64 @@ static inline void Vec_IntSortUnsigned( Vec_Int_t * p )
(int (*)(const void *, const void *)) Vec_IntSortCompareUnsigned );
}
+/**Function*************************************************************
+
+ Synopsis [Returns the number of common entries.]
+
+ Description [Assumes that the vectors are sorted in the increasing order.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Vec_IntTwoCountCommon( Vec_Int_t * vArr1, Vec_Int_t * vArr2 )
+{
+ int i, k, Counter = 0;
+ for ( i = k = 0; i < Vec_IntSize(vArr1) && k < Vec_IntSize(vArr2); )
+ {
+ if ( Vec_IntEntry(vArr1,i) == Vec_IntEntry(vArr2,k) )
+ Counter++, i++, k++;
+ else if ( Vec_IntEntry(vArr1,i) < Vec_IntEntry(vArr2,k) )
+ i++;
+ else
+ k++;
+ }
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the result of merging the two vectors.]
+
+ Description [Assumes that the vectors are sorted in the increasing order.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Vec_Int_t * Vec_IntTwoMerge( Vec_Int_t * vArr1, Vec_Int_t * vArr2 )
+{
+ Vec_Int_t * vArr;
+ int i, k;
+ vArr = Vec_IntAlloc( Vec_IntSize(vArr1) );
+ for ( i = k = 0; i < Vec_IntSize(vArr1) && k < Vec_IntSize(vArr2); )
+ {
+ if ( Vec_IntEntry(vArr1,i) == Vec_IntEntry(vArr2,k) )
+ Vec_IntPush( vArr, Vec_IntEntry(vArr1,i) ), i++, k++;
+ else if ( Vec_IntEntry(vArr1,i) < Vec_IntEntry(vArr2,k) )
+ Vec_IntPush( vArr, Vec_IntEntry(vArr1,i) ), i++;
+ else
+ Vec_IntPush( vArr, Vec_IntEntry(vArr2,k) ), k++;
+ }
+ for ( ; i < Vec_IntSize(vArr1); i++ )
+ Vec_IntPush( vArr, Vec_IntEntry(vArr1,i) );
+ for ( ; k < Vec_IntSize(vArr2); k++ )
+ Vec_IntPush( vArr, Vec_IntEntry(vArr2,k) );
+ return vArr;
+}
+
#endif
////////////////////////////////////////////////////////////////////////