summaryrefslogtreecommitdiffstats
path: root/src/misc/vec
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2016-05-07 19:47:02 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2016-05-07 19:47:02 -0700
commit236d412255e5007adac97c05e759bfd5069bc1c1 (patch)
tree8b43abfb5798f47586e6f5dcd0acf8a07f61a722 /src/misc/vec
parent40d90ae69c4bb84e20e98aab127788a8b1755faa (diff)
downloadabc-236d412255e5007adac97c05e759bfd5069bc1c1.tar.gz
abc-236d412255e5007adac97c05e759bfd5069bc1c1.tar.bz2
abc-236d412255e5007adac97c05e759bfd5069bc1c1.zip
Experiments with CEC for arithmetic circuits.
Diffstat (limited to 'src/misc/vec')
-rw-r--r--src/misc/vec/vecInt.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/misc/vec/vecInt.h b/src/misc/vec/vecInt.h
index e0e2ba7f..f09b8783 100644
--- a/src/misc/vec/vecInt.h
+++ b/src/misc/vec/vecInt.h
@@ -804,6 +804,24 @@ static inline void Vec_IntPushOrder( Vec_Int_t * p, int Entry )
break;
p->pArray[i+1] = Entry;
}
+static inline void Vec_IntPushOrderCost( Vec_Int_t * p, int Entry, Vec_Int_t * vCost )
+{
+ int i;
+ if ( p->nSize == p->nCap )
+ {
+ if ( p->nCap < 16 )
+ Vec_IntGrow( p, 16 );
+ else
+ Vec_IntGrow( p, 2 * p->nCap );
+ }
+ p->nSize++;
+ for ( i = p->nSize-2; i >= 0; i-- )
+ if ( Vec_IntEntry(vCost, p->pArray[i]) > Vec_IntEntry(vCost, Entry) )
+ p->pArray[i+1] = p->pArray[i];
+ else
+ break;
+ p->pArray[i+1] = Entry;
+}
/**Function*************************************************************
@@ -855,6 +873,15 @@ static inline int Vec_IntPushUniqueOrder( Vec_Int_t * p, int Entry )
Vec_IntPushOrder( p, Entry );
return 0;
}
+static inline int Vec_IntPushUniqueOrderCost( Vec_Int_t * p, int Entry, Vec_Int_t * vCost )
+{
+ int i;
+ for ( i = 0; i < p->nSize; i++ )
+ if ( p->pArray[i] == Entry )
+ return 1;
+ Vec_IntPushOrderCost( p, Entry, vCost );
+ return 0;
+}
/**Function*************************************************************