summaryrefslogtreecommitdiffstats
path: root/src/misc
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2015-01-31 19:52:32 -0800
committerAlan Mishchenko <alanmi@berkeley.edu>2015-01-31 19:52:32 -0800
commit77dbe2b6565dbc68a04a315fb51b50a35b763228 (patch)
tree8b8c4bddbd01a69314178d33a8b739867d38f78d /src/misc
parenta523ab792c4627c11a57fce9a002f3a5bd4bae45 (diff)
downloadabc-77dbe2b6565dbc68a04a315fb51b50a35b763228.tar.gz
abc-77dbe2b6565dbc68a04a315fb51b50a35b763228.tar.bz2
abc-77dbe2b6565dbc68a04a315fb51b50a35b763228.zip
Major rehash of the CBA code.
Diffstat (limited to 'src/misc')
-rw-r--r--src/misc/util/utilNam.c2
-rw-r--r--src/misc/vec/vecInt.h23
-rw-r--r--src/misc/vec/vecStr.h33
3 files changed, 56 insertions, 2 deletions
diff --git a/src/misc/util/utilNam.c b/src/misc/util/utilNam.c
index e5e04b7f..3be805aa 100644
--- a/src/misc/util/utilNam.c
+++ b/src/misc/util/utilNam.c
@@ -478,7 +478,7 @@ int Abc_NamStrFindOrAddLim( Abc_Nam_t * p, char * pStr, char * pLim, int * pfFou
***********************************************************************/
char * Abc_NamStr( Abc_Nam_t * p, int NameId )
{
- return NameId? Abc_NamIntToStr(p, NameId) : NULL;
+ return NameId > 0 ? Abc_NamIntToStr(p, NameId) : NULL;
}
/**Function*************************************************************
diff --git a/src/misc/vec/vecInt.h b/src/misc/vec/vecInt.h
index e37743c5..b1aa556b 100644
--- a/src/misc/vec/vecInt.h
+++ b/src/misc/vec/vecInt.h
@@ -65,7 +65,9 @@ struct Vec_Int_t_
for ( i = 0; (i < Vec_IntSize(vVec1)) && (((Entry1) = Vec_IntEntry(vVec1, i)), 1) && (((Entry2) = Vec_IntEntry(vVec2, i)), 1); i++ )
#define Vec_IntForEachEntryDouble( vVec, Entry1, Entry2, i ) \
for ( i = 0; (i+1 < Vec_IntSize(vVec)) && (((Entry1) = Vec_IntEntry(vVec, i)), 1) && (((Entry2) = Vec_IntEntry(vVec, i+1)), 1); i += 2 )
-#define Vec_IntForEachEntryTriple( vVec, Entry1, Entry2, Entry3, i ) \
+#define Vec_IntForEachEntryDoubleStart( vVec, Entry1, Entry2, i, Start ) \
+ for ( i = Start; (i+1 < Vec_IntSize(vVec)) && (((Entry1) = Vec_IntEntry(vVec, i)), 1) && (((Entry2) = Vec_IntEntry(vVec, i+1)), 1); i += 2 )
+#define Vec_IntForEachEntryTriple( vVec, Entry1, Entry2, Entry3, i ) \
for ( i = 0; (i+2 < Vec_IntSize(vVec)) && (((Entry1) = Vec_IntEntry(vVec, i)), 1) && (((Entry2) = Vec_IntEntry(vVec, i+1)), 1) && (((Entry3) = Vec_IntEntry(vVec, i+2)), 1); i += 3 )
#define Vec_IntForEachEntryThisNext( vVec, This, Next, i ) \
for ( i = 0, (This) = (Next) = (Vec_IntSize(vVec) ? Vec_IntEntry(vVec, 0) : -1); (i+1 < Vec_IntSize(vVec)) && (((Next) = Vec_IntEntry(vVec, i+1)), 1); i += 2, (This) = (Next) )
@@ -613,6 +615,11 @@ static inline int Vec_IntGetEntry( Vec_Int_t * p, int i )
Vec_IntFillExtra( p, i + 1, 0 );
return Vec_IntEntry( p, i );
}
+static inline int Vec_IntGetEntryFull( Vec_Int_t * p, int i )
+{
+ Vec_IntFillExtra( p, i + 1, -1 );
+ return Vec_IntEntry( p, i );
+}
/**Function*************************************************************
@@ -1170,6 +1177,20 @@ static inline int Vec_IntCountEntry( Vec_Int_t * p, int Entry )
Counter += (p->pArray[i] == Entry);
return Counter;
}
+static inline int Vec_IntCountLarger( Vec_Int_t * p, int Entry )
+{
+ int i, Counter = 0;
+ for ( i = 0; i < p->nSize; i++ )
+ Counter += (p->pArray[i] > Entry);
+ return Counter;
+}
+static inline int Vec_IntCountSmaller( Vec_Int_t * p, int Entry )
+{
+ int i, Counter = 0;
+ for ( i = 0; i < p->nSize; i++ )
+ Counter += (p->pArray[i] < Entry);
+ return Counter;
+}
/**Function*************************************************************
diff --git a/src/misc/vec/vecStr.h b/src/misc/vec/vecStr.h
index 4198ac82..b8a8433d 100644
--- a/src/misc/vec/vecStr.h
+++ b/src/misc/vec/vecStr.h
@@ -706,6 +706,39 @@ static inline int Vec_StrSum( Vec_Str_t * p )
/**Function*************************************************************
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Vec_StrCountEntry( Vec_Str_t * p, char Entry )
+{
+ int i, Counter = 0;
+ for ( i = 0; i < p->nSize; i++ )
+ Counter += (p->pArray[i] == Entry);
+ return Counter;
+}
+static inline int Vec_StrCountLarger( Vec_Str_t * p, char Entry )
+{
+ int i, Counter = 0;
+ for ( i = 0; i < p->nSize; i++ )
+ Counter += (p->pArray[i] > Entry);
+ return Counter;
+}
+static inline int Vec_StrCountSmaller( Vec_Str_t * p, char Entry )
+{
+ int i, Counter = 0;
+ for ( i = 0; i < p->nSize; i++ )
+ Counter += (p->pArray[i] < Entry);
+ return Counter;
+}
+
+/**Function*************************************************************
+
Synopsis [Compares two strings.]
Description []