From e2f15482175a06a9aa9056a3a54b2bb05de2721a Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Tue, 21 Sep 2021 10:00:46 -0700 Subject: Various changes. --- src/misc/vec/vecInt.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'src/misc/vec') diff --git a/src/misc/vec/vecInt.h b/src/misc/vec/vecInt.h index c2f8cd61..df90f73f 100644 --- a/src/misc/vec/vecInt.h +++ b/src/misc/vec/vecInt.h @@ -862,6 +862,52 @@ static inline void Vec_IntPushOrderCost( Vec_Int_t * p, int Entry, Vec_Int_t * v p->pArray[i+1] = Entry; } +/**Function************************************************************* + + Synopsis [Check if the array is ordered.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Vec_IntIsOrdered( Vec_Int_t * p, int fReverse ) +{ + int i; + if ( fReverse ) + { + for ( i = 1; i < p->nSize; i++ ) + if ( p->pArray[i-1] < p->pArray[i] ) + return 0; + } + else + { + for ( i = 1; i < p->nSize; i++ ) + if ( p->pArray[i-1] > p->pArray[i] ) + return 0; + } + return 1; +} +static inline int Vec_IntIsOrderedCost( Vec_Int_t * p, Vec_Int_t * vCost, int fReverse ) +{ + int i; + if ( fReverse ) + { + for ( i = 1; i < p->nSize; i++ ) + if ( Vec_IntEntry(vCost, p->pArray[i-1]) < Vec_IntEntry(vCost, p->pArray[i]) ) + return 0; + } + else + { + for ( i = 1; i < p->nSize; i++ ) + if ( Vec_IntEntry(vCost, p->pArray[i-1]) > Vec_IntEntry(vCost, p->pArray[i]) ) + return 0; + } + return 1; +} + /**Function************************************************************* Synopsis [Inserts the entry while preserving the increasing order.] -- cgit v1.2.3