summaryrefslogtreecommitdiffstats
path: root/src/misc
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2021-11-02 20:28:01 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2021-11-02 20:28:01 -0700
commita80a91e45f5edf59fb7475ae1a461ba3602c6731 (patch)
treeda1dbf75d8451da0644549aa5d182ffd7b759e09 /src/misc
parentd13e33cdd8451ad4ecfcb9093fbaa628f0e6659d (diff)
downloadabc-a80a91e45f5edf59fb7475ae1a461ba3602c6731.tar.gz
abc-a80a91e45f5edf59fb7475ae1a461ba3602c6731.tar.bz2
abc-a80a91e45f5edf59fb7475ae1a461ba3602c6731.zip
Bug fix and new procedures.
Diffstat (limited to 'src/misc')
-rw-r--r--src/misc/vec/vecInt.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/misc/vec/vecInt.h b/src/misc/vec/vecInt.h
index 89a9096a..83122796 100644
--- a/src/misc/vec/vecInt.h
+++ b/src/misc/vec/vecInt.h
@@ -1934,6 +1934,70 @@ static inline int Vec_IntTwoRemove( Vec_Int_t * vArr1, Vec_Int_t * vArr2 )
Synopsis [Returns the result of merging the two vectors.]
+ Description [Keeps only those entries of vArr1, which are in vArr2.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_IntTwoMerge1( Vec_Int_t * vArr1, Vec_Int_t * vArr2 )
+{
+ int * pBeg = vArr1->pArray;
+ int * pBeg1 = vArr1->pArray;
+ int * pBeg2 = vArr2->pArray;
+ int * pEnd1 = vArr1->pArray + vArr1->nSize;
+ int * pEnd2 = vArr2->pArray + vArr2->nSize;
+ while ( pBeg1 < pEnd1 && pBeg2 < pEnd2 )
+ {
+ if ( *pBeg1 == *pBeg2 )
+ *pBeg++ = *pBeg1++, pBeg2++;
+ else if ( *pBeg1 < *pBeg2 )
+ *pBeg1++;
+ else
+ *pBeg2++;
+ }
+ assert( vArr1->nSize >= pBeg - vArr1->pArray );
+ vArr1->nSize = pBeg - vArr1->pArray;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the result of subtracting for two vectors.]
+
+ Description [Keeps only those entries of vArr1, which are not in vArr2.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_IntTwoRemove1( Vec_Int_t * vArr1, Vec_Int_t * vArr2 )
+{
+ int * pBeg = vArr1->pArray;
+ int * pBeg1 = vArr1->pArray;
+ int * pBeg2 = vArr2->pArray;
+ int * pEnd1 = vArr1->pArray + vArr1->nSize;
+ int * pEnd2 = vArr2->pArray + vArr2->nSize;
+ while ( pBeg1 < pEnd1 && pBeg2 < pEnd2 )
+ {
+ if ( *pBeg1 == *pBeg2 )
+ *pBeg1++, pBeg2++;
+ else if ( *pBeg1 < *pBeg2 )
+ *pBeg++ = *pBeg1++;
+ else
+ *pBeg2++;
+ }
+ while ( pBeg1 < pEnd1 )
+ *pBeg++ = *pBeg1++;
+ assert( vArr1->nSize >= pBeg - vArr1->pArray );
+ vArr1->nSize = pBeg - vArr1->pArray;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the result of merging the two vectors.]
+
Description [Assumes that the vectors are sorted in the increasing order.]
SideEffects []