summaryrefslogtreecommitdiffstats
path: root/src/misc/vec
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2021-09-21 10:00:46 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2021-09-21 10:00:46 -0700
commite2f15482175a06a9aa9056a3a54b2bb05de2721a (patch)
tree17960c2c61a317d3b593dc350800f5ca787316e4 /src/misc/vec
parent6ca31c475f7ae1605be34a0629559db2beef49d1 (diff)
downloadabc-e2f15482175a06a9aa9056a3a54b2bb05de2721a.tar.gz
abc-e2f15482175a06a9aa9056a3a54b2bb05de2721a.tar.bz2
abc-e2f15482175a06a9aa9056a3a54b2bb05de2721a.zip
Various changes.
Diffstat (limited to 'src/misc/vec')
-rw-r--r--src/misc/vec/vecInt.h46
1 files changed, 46 insertions, 0 deletions
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
@@ -864,6 +864,52 @@ static inline void Vec_IntPushOrderCost( Vec_Int_t * p, int Entry, Vec_Int_t * v
/**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.]
Description []