summaryrefslogtreecommitdiffstats
path: root/src/misc/vec
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2021-09-02 22:54:19 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2021-09-02 22:54:19 -0700
commita718318740a3a50f6058b3d64330dbe8ca1e6303 (patch)
tree047f662a949e3e2d691b132ac5decfa6b621029f /src/misc/vec
parent388255e557cf973616c84c32307366f79822295a (diff)
downloadabc-a718318740a3a50f6058b3d64330dbe8ca1e6303.tar.gz
abc-a718318740a3a50f6058b3d64330dbe8ca1e6303.tar.bz2
abc-a718318740a3a50f6058b3d64330dbe8ca1e6303.zip
Various changes.
Diffstat (limited to 'src/misc/vec')
-rw-r--r--src/misc/vec/vecInt.h35
-rw-r--r--src/misc/vec/vecWec.h7
2 files changed, 42 insertions, 0 deletions
diff --git a/src/misc/vec/vecInt.h b/src/misc/vec/vecInt.h
index 5e545698..cbe20903 100644
--- a/src/misc/vec/vecInt.h
+++ b/src/misc/vec/vecInt.h
@@ -150,6 +150,23 @@ static inline Vec_Int_t * Vec_IntStartRange( int First, int Range )
p->pArray[i] = First + i;
return p;
}
+static inline Vec_Int_t * Vec_IntStartRandomLimit( int nSize, int Upper, int Lower )
+{
+ Vec_Int_t * p = Vec_IntAlloc( nSize );
+ int i, Gap = Upper - Lower + 1;
+ for ( i = 0; i < p->nSize; i++ )
+ p->pArray[i] = Lower + Abc_Random(0) % Gap;
+ return p;
+}
+static inline void Vec_IntRandomizeOrder( Vec_Int_t * p )
+{
+ int v;
+ for ( v = 0; v < p->nSize; v++ )
+ {
+ int vRand = Abc_Random(0) % p->nSize;
+ ABC_SWAP( int, p->pArray[vRand], p->pArray[v] );
+ }
+}
/**Function*************************************************************
@@ -734,6 +751,11 @@ static inline void Vec_IntPush( Vec_Int_t * p, int Entry )
}
p->pArray[p->nSize++] = Entry;
}
+static inline int Vec_IntPushReturn( Vec_Int_t * p, int Entry )
+{
+ Vec_IntPush( p, Entry );
+ return Entry;
+}
static inline void Vec_IntPushTwo( Vec_Int_t * p, int Entry1, int Entry2 )
{
Vec_IntPush( p, Entry1 );
@@ -1318,6 +1340,19 @@ static inline int Vec_IntEqual( Vec_Int_t * p1, Vec_Int_t * p2 )
return 0;
return 1;
}
+static inline int Vec_IntContained( Vec_Int_t * pSmall, Vec_Int_t * pLarge )
+{
+ int i, k;
+ for ( i = 0; i < pSmall->nSize; i++ )
+ {
+ for ( k = 0; k < pLarge->nSize; k++ )
+ if ( pSmall->pArray[i] == pLarge->pArray[k] )
+ break;
+ if ( k == pLarge->nSize )
+ return 0;
+ }
+ return 1;
+}
/**Function*************************************************************
diff --git a/src/misc/vec/vecWec.h b/src/misc/vec/vecWec.h
index 00eda198..26d026c7 100644
--- a/src/misc/vec/vecWec.h
+++ b/src/misc/vec/vecWec.h
@@ -275,6 +275,13 @@ static inline void Vec_WecClear( Vec_Wec_t * p )
Vec_IntClear( vVec );
p->nSize = 0;
}
+static inline void Vec_WecClearLevels( Vec_Wec_t * p )
+{
+ Vec_Int_t * vVec;
+ int i;
+ Vec_WecForEachLevel( p, vVec, i )
+ Vec_IntClear( vVec );
+}
/**Function*************************************************************