From a80a91e45f5edf59fb7475ae1a461ba3602c6731 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Tue, 2 Nov 2021 20:28:01 -0700 Subject: Bug fix and new procedures. --- src/misc/vec/vecInt.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'src/misc/vec') 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 @@ -1930,6 +1930,70 @@ static inline int Vec_IntTwoRemove( Vec_Int_t * vArr1, Vec_Int_t * vArr2 ) return Vec_IntSize(vArr1); } +/**Function************************************************************* + + 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.] -- cgit v1.2.3