From 6a4e94e74de5158280ca6959b17c2c86db1299a4 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 9 Aug 2015 13:18:22 -0700 Subject: Improvements to Cba data-structure. --- src/misc/util/utilNam.c | 8 ++------ src/misc/vec/vecHash.h | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 8 deletions(-) (limited to 'src/misc') diff --git a/src/misc/util/utilNam.c b/src/misc/util/utilNam.c index 49a3ae6a..6cb180c0 100644 --- a/src/misc/util/utilNam.c +++ b/src/misc/util/utilNam.c @@ -133,13 +133,9 @@ void Abc_NamStop( Abc_Nam_t * p ) ***********************************************************************/ void Abc_NamPrint( Abc_Nam_t * p ) { - int h, i, Counter = 0; + int h, i; Vec_IntForEachEntryStart( &p->vInt2Handle, h, i, 1 ) - if ( Abc_NamHandleToStr(p, h)[0] == '[' ) - Abc_Print( 1, "%s ", Abc_NamHandleToStr(p, h) ), Counter++; -// Abc_Print( 1, "%d=\n%s\n", i, Abc_NamHandleToStr(p, h) ); -// Abc_Print( 1, "\n" ); - printf( " %d\n", Counter ); + Abc_Print( 1, "%d=\n%s\n", i, Abc_NamHandleToStr(p, h) ); } /**Function************************************************************* diff --git a/src/misc/vec/vecHash.h b/src/misc/vec/vecHash.h index cdccb308..9945024c 100644 --- a/src/misc/vec/vecHash.h +++ b/src/misc/vec/vecHash.h @@ -53,6 +53,7 @@ struct Hash_IntMan_t_ { Vec_Int_t * vTable; // hash table Vec_Int_t * vObjs; // hash objects + int nRefs; // reference counter for the manager }; //////////////////////////////////////////////////////////////////////// @@ -74,7 +75,7 @@ static inline void Hash_Int2ObjSetData2( Hash_IntMan_t * p, int i, in /**Function************************************************************* - Synopsis [Hashing data entries composed of nSize integers.] + Synopsis [Hashes pairs of intergers.] Description [] @@ -90,6 +91,7 @@ static inline Hash_IntMan_t * Hash_IntManStart( int nSize ) p->vTable = Vec_IntStart( Abc_PrimeCudd(nSize) ); p->vObjs = Vec_IntAlloc( 4*nSize ); Vec_IntFill( p->vObjs, 4, 0 ); + p->nRefs = 1; return p; } static inline void Hash_IntManStop( Hash_IntMan_t * p ) @@ -98,6 +100,18 @@ static inline void Hash_IntManStop( Hash_IntMan_t * p ) Vec_IntFree( p->vTable ); ABC_FREE( p ); } +static inline Hash_IntMan_t * Hash_IntManRef( Hash_IntMan_t * p ) +{ + p->nRefs++; + return p; +} +static inline void Hash_IntManDeref( Hash_IntMan_t * p ) +{ + if ( p == NULL ) + return; + if ( --p->nRefs == 0 ) + Hash_IntManStop( p ); +} static inline int Hash_IntManEntryNum( Hash_IntMan_t * p ) { return Vec_IntSize(p->vObjs)/4 - 1; @@ -172,7 +186,7 @@ static inline int Hash_Int2ManInsert( Hash_IntMan_t * p, int iData0, int iData1, /**Function************************************************************* - Synopsis [] + Synopsis [Hashes triples of intergers.] Description [] -- cgit v1.2.3