abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
vecHash.h File Reference
#include <stdio.h>

Go to the source code of this file.

Data Structures

struct  Hash_IntObj_t_
 
struct  Hash_IntMan_t_
 

Typedefs

typedef
typedefABC_NAMESPACE_HEADER_START
struct Hash_IntObj_t_ 
Hash_IntObj_t
 INCLUDES ///. More...
 
typedef struct Hash_IntMan_t_ Hash_IntMan_t
 

Functions

static Hash_IntObj_tHash_IntObj (Hash_IntMan_t *p, int i)
 MACRO DEFINITIONS ///. More...
 
static int Hash_IntObjData0 (Hash_IntMan_t *p, int i)
 
static int Hash_IntObjData1 (Hash_IntMan_t *p, int i)
 
static int Hash_IntObjData2 (Hash_IntMan_t *p, int i)
 
static int Hash_Int2ObjInc (Hash_IntMan_t *p, int i)
 
static int Hash_Int2ObjDec (Hash_IntMan_t *p, int i)
 
static void Hash_Int2ObjSetData2 (Hash_IntMan_t *p, int i, int d)
 
static Hash_IntMan_tHash_IntManStart (int nSize)
 FUNCTION DEFINITIONS ///. More...
 
static void Hash_IntManStop (Hash_IntMan_t *p)
 
static int Hash_IntManEntryNum (Hash_IntMan_t *p)
 
static void Hash_IntManProfile (Hash_IntMan_t *p)
 
static int Hash_Int2ManHash (int iData0, int iData1, int nTableSize)
 
static int * Hash_Int2ManLookup (Hash_IntMan_t *p, int iData0, int iData1)
 
static int Hash_Int2ManInsert (Hash_IntMan_t *p, int iData0, int iData1, int iData2)
 
static int Hsh_Int3ManHash (int iData0, int iData1, int iData2, int nTableSize)
 
static int * Hsh_Int3ManLookup (Hash_IntMan_t *p, int iData0, int iData1, int iData2)
 
static int Hsh_Int3ManInsert (Hash_IntMan_t *p, int iData0, int iData1, int iData2)
 
static void Hash_IntManHashArrayTest ()
 

Typedef Documentation

typedef struct Hash_IntMan_t_ Hash_IntMan_t

Definition at line 51 of file vecHash.h.

typedef typedefABC_NAMESPACE_HEADER_START struct Hash_IntObj_t_ Hash_IntObj_t

INCLUDES ///.

CFile****************************************************************

FileName [vecHash.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Resizable arrays.]

Synopsis [Hashing integer pairs/triples into an integer.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
vecHash.h,v 1.00 2005/06/20 00:00:00 alanmi Exp

]PARAMETERS ///BASIC TYPES ///

Definition at line 42 of file vecHash.h.

Function Documentation

static int Hash_Int2ManHash ( int  iData0,
int  iData1,
int  nTableSize 
)
inlinestatic

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 130 of file vecHash.h.

131 {
132  return (4177 * (unsigned)iData0 + 7873 * (unsigned)iData1) % (unsigned)nTableSize;
133 }
static int Hash_Int2ManInsert ( Hash_IntMan_t p,
int  iData0,
int  iData1,
int  iData2 
)
inlinestatic

Definition at line 144 of file vecHash.h.

145 {
146  Hash_IntObj_t * pObj;
147  int i, nObjs, * pPlace;
148  nObjs = Vec_IntSize(p->vObjs)/4;
149  if ( nObjs > Vec_IntSize(p->vTable) )
150  {
151 // printf( "Resizing...\n" );
153  for ( i = 1; i < nObjs; i++ )
154  {
155  pObj = Hash_IntObj( p, i );
156  pObj->iNext = 0;
157  pPlace = Hash_Int2ManLookup( p, pObj->iData0, pObj->iData1 );
158  assert( *pPlace == 0 );
159  *pPlace = i;
160  }
161  }
162  pPlace = Hash_Int2ManLookup( p, iData0, iData1 );
163  if ( *pPlace )
164  return *pPlace;
165  *pPlace = nObjs;
166  Vec_IntPush( p->vObjs, iData0 );
167  Vec_IntPush( p->vObjs, iData1 );
168  Vec_IntPush( p->vObjs, iData2 );
169  Vec_IntPush( p->vObjs, 0 );
170  return nObjs;
171 }
static int Abc_PrimeCudd(unsigned int p)
Definition: abc_global.h:383
Vec_Int_t * vObjs
Definition: vecHash.h:55
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int * Hash_Int2ManLookup(Hash_IntMan_t *p, int iData0, int iData1)
Definition: vecHash.h:134
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
typedefABC_NAMESPACE_HEADER_START struct Hash_IntObj_t_ Hash_IntObj_t
INCLUDES ///.
Definition: vecHash.h:42
static Hash_IntObj_t * Hash_IntObj(Hash_IntMan_t *p, int i)
MACRO DEFINITIONS ///.
Definition: vecHash.h:62
#define assert(ex)
Definition: util_old.h:213
Vec_Int_t * vTable
Definition: vecHash.h:54
static int* Hash_Int2ManLookup ( Hash_IntMan_t p,
int  iData0,
int  iData1 
)
inlinestatic

Definition at line 134 of file vecHash.h.

135 {
136  Hash_IntObj_t * pObj;
137  int * pPlace = Vec_IntEntryP( p->vTable, Hash_Int2ManHash(iData0, iData1, Vec_IntSize(p->vTable)) );
138  for ( ; (pObj = Hash_IntObj(p, *pPlace)); pPlace = &pObj->iNext )
139  if ( pObj->iData0 == iData0 && pObj->iData1 == iData1 )
140  return pPlace;
141  assert( *pPlace == 0 );
142  return pPlace;
143 }
static int Hash_Int2ManHash(int iData0, int iData1, int nTableSize)
Definition: vecHash.h:130
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
typedefABC_NAMESPACE_HEADER_START struct Hash_IntObj_t_ Hash_IntObj_t
INCLUDES ///.
Definition: vecHash.h:42
static Hash_IntObj_t * Hash_IntObj(Hash_IntMan_t *p, int i)
MACRO DEFINITIONS ///.
Definition: vecHash.h:62
#define assert(ex)
Definition: util_old.h:213
static int * Vec_IntEntryP(Vec_Int_t *p, int i)
Definition: vecInt.h:417
Vec_Int_t * vTable
Definition: vecHash.h:54
static int Hash_Int2ObjDec ( Hash_IntMan_t p,
int  i 
)
inlinestatic

Definition at line 68 of file vecHash.h.

68 { return --Hash_IntObj(p, i)->iData2; }
static Hash_IntObj_t * Hash_IntObj(Hash_IntMan_t *p, int i)
MACRO DEFINITIONS ///.
Definition: vecHash.h:62
static int Hash_Int2ObjInc ( Hash_IntMan_t p,
int  i 
)
inlinestatic

Definition at line 67 of file vecHash.h.

67 { return Hash_IntObj(p, i)->iData2++; }
static Hash_IntObj_t * Hash_IntObj(Hash_IntMan_t *p, int i)
MACRO DEFINITIONS ///.
Definition: vecHash.h:62
static void Hash_Int2ObjSetData2 ( Hash_IntMan_t p,
int  i,
int  d 
)
inlinestatic

Definition at line 69 of file vecHash.h.

69 { Hash_IntObj(p, i)->iData2 = d; }
static Hash_IntObj_t * Hash_IntObj(Hash_IntMan_t *p, int i)
MACRO DEFINITIONS ///.
Definition: vecHash.h:62
static int Hash_IntManEntryNum ( Hash_IntMan_t p)
inlinestatic

Definition at line 101 of file vecHash.h.

102 {
103  return Vec_IntSize(p->vObjs)/4 - 1;
104 }
Vec_Int_t * vObjs
Definition: vecHash.h:55
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static void Hash_IntManHashArrayTest ( )
inlinestatic

Function*************************************************************

Synopsis [Test procedure.]

Description []

SideEffects []

SeeAlso []

Definition at line 238 of file vecHash.h.

239 {
240  Hash_IntMan_t * p;
241  int RetValue;
242 
243  p = Hash_IntManStart( 10 );
244 
245  RetValue = Hash_Int2ManInsert( p, 10, 11, 12 );
246  assert( RetValue );
247 
248  RetValue = Hash_Int2ManInsert( p, 20, 21, 22 );
249  assert( RetValue );
250 
251  RetValue = Hash_Int2ManInsert( p, 10, 11, 12 );
252  assert( !RetValue );
253 
254  Hash_IntManStop( p );
255 }
static Hash_IntMan_t * Hash_IntManStart(int nSize)
FUNCTION DEFINITIONS ///.
Definition: vecHash.h:86
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Hash_IntManStop(Hash_IntMan_t *p)
Definition: vecHash.h:95
static int Hash_Int2ManInsert(Hash_IntMan_t *p, int iData0, int iData1, int iData2)
Definition: vecHash.h:144
#define assert(ex)
Definition: util_old.h:213
static void Hash_IntManProfile ( Hash_IntMan_t p)
inlinestatic

Definition at line 105 of file vecHash.h.

106 {
107  Hash_IntObj_t * pObj;
108  int i, Count, Entry;
109  Vec_IntForEachEntry( p->vTable, Entry, i )
110  {
111  Count = 0;
112  for ( pObj = Hash_IntObj( p, Entry ); pObj; pObj = Hash_IntObj( p, pObj->iNext ) )
113  Count++;
114  printf( "%d ", Count );
115  }
116  printf( "\n" );
117 }
typedefABC_NAMESPACE_HEADER_START struct Hash_IntObj_t_ Hash_IntObj_t
INCLUDES ///.
Definition: vecHash.h:42
static Hash_IntObj_t * Hash_IntObj(Hash_IntMan_t *p, int i)
MACRO DEFINITIONS ///.
Definition: vecHash.h:62
Vec_Int_t * vTable
Definition: vecHash.h:54
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static Hash_IntMan_t* Hash_IntManStart ( int  nSize)
inlinestatic

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Hashing data entries composed of nSize integers.]

Description []

SideEffects []

SeeAlso []

Definition at line 86 of file vecHash.h.

87 {
88  Hash_IntMan_t * p; nSize += 100;
89  p = ABC_CALLOC( Hash_IntMan_t, 1 );
90  p->vTable = Vec_IntStart( Abc_PrimeCudd(nSize) );
91  p->vObjs = Vec_IntAlloc( 4*nSize );
92  Vec_IntFill( p->vObjs, 4, 0 );
93  return p;
94 }
static int Abc_PrimeCudd(unsigned int p)
Definition: abc_global.h:383
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Vec_Int_t * vObjs
Definition: vecHash.h:55
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
Vec_Int_t * vTable
Definition: vecHash.h:54
static void Hash_IntManStop ( Hash_IntMan_t p)
inlinestatic

Definition at line 95 of file vecHash.h.

96 {
97  Vec_IntFree( p->vObjs );
98  Vec_IntFree( p->vTable );
99  ABC_FREE( p );
100 }
Vec_Int_t * vObjs
Definition: vecHash.h:55
#define ABC_FREE(obj)
Definition: abc_global.h:232
Vec_Int_t * vTable
Definition: vecHash.h:54
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static Hash_IntObj_t* Hash_IntObj ( Hash_IntMan_t p,
int  i 
)
inlinestatic

MACRO DEFINITIONS ///.

Definition at line 62 of file vecHash.h.

62 { return i ? (Hash_IntObj_t *)Vec_IntEntryP(p->vObjs, 4*i) : NULL; }
Vec_Int_t * vObjs
Definition: vecHash.h:55
typedefABC_NAMESPACE_HEADER_START struct Hash_IntObj_t_ Hash_IntObj_t
INCLUDES ///.
Definition: vecHash.h:42
static int * Vec_IntEntryP(Vec_Int_t *p, int i)
Definition: vecInt.h:417
static int Hash_IntObjData0 ( Hash_IntMan_t p,
int  i 
)
inlinestatic

Definition at line 63 of file vecHash.h.

63 { return Hash_IntObj(p, i)->iData0; }
static Hash_IntObj_t * Hash_IntObj(Hash_IntMan_t *p, int i)
MACRO DEFINITIONS ///.
Definition: vecHash.h:62
static int Hash_IntObjData1 ( Hash_IntMan_t p,
int  i 
)
inlinestatic

Definition at line 64 of file vecHash.h.

64 { return Hash_IntObj(p, i)->iData1; }
static Hash_IntObj_t * Hash_IntObj(Hash_IntMan_t *p, int i)
MACRO DEFINITIONS ///.
Definition: vecHash.h:62
static int Hash_IntObjData2 ( Hash_IntMan_t p,
int  i 
)
inlinestatic

Definition at line 65 of file vecHash.h.

65 { return Hash_IntObj(p, i)->iData2; }
static Hash_IntObj_t * Hash_IntObj(Hash_IntMan_t *p, int i)
MACRO DEFINITIONS ///.
Definition: vecHash.h:62
static int Hsh_Int3ManHash ( int  iData0,
int  iData1,
int  iData2,
int  nTableSize 
)
inlinestatic

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 184 of file vecHash.h.

185 {
186  return (4177 * (unsigned)iData0 + 7873 * (unsigned)iData1 + 1699 * (unsigned)iData2) % (unsigned)nTableSize;
187 }
static int Hsh_Int3ManInsert ( Hash_IntMan_t p,
int  iData0,
int  iData1,
int  iData2 
)
inlinestatic

Definition at line 198 of file vecHash.h.

199 {
200  Hash_IntObj_t * pObj;
201  int i, nObjs, * pPlace;
202  nObjs = Vec_IntSize(p->vObjs)/4;
203  if ( nObjs > Vec_IntSize(p->vTable) )
204  {
205 // printf( "Resizing...\n" );
207  for ( i = 1; i < nObjs; i++ )
208  {
209  pObj = Hash_IntObj( p, i );
210  pObj->iNext = 0;
211  pPlace = Hsh_Int3ManLookup( p, pObj->iData0, pObj->iData1, pObj->iData2 );
212  assert( *pPlace == 0 );
213  *pPlace = i;
214  }
215  }
216  pPlace = Hsh_Int3ManLookup( p, iData0, iData1, iData2 );
217  if ( *pPlace )
218  return *pPlace;
219  *pPlace = nObjs;
220  Vec_IntPush( p->vObjs, iData0 );
221  Vec_IntPush( p->vObjs, iData1 );
222  Vec_IntPush( p->vObjs, iData2 );
223  Vec_IntPush( p->vObjs, 0 );
224  return nObjs;
225 }
static int Abc_PrimeCudd(unsigned int p)
Definition: abc_global.h:383
static int * Hsh_Int3ManLookup(Hash_IntMan_t *p, int iData0, int iData1, int iData2)
Definition: vecHash.h:188
Vec_Int_t * vObjs
Definition: vecHash.h:55
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
typedefABC_NAMESPACE_HEADER_START struct Hash_IntObj_t_ Hash_IntObj_t
INCLUDES ///.
Definition: vecHash.h:42
static Hash_IntObj_t * Hash_IntObj(Hash_IntMan_t *p, int i)
MACRO DEFINITIONS ///.
Definition: vecHash.h:62
#define assert(ex)
Definition: util_old.h:213
Vec_Int_t * vTable
Definition: vecHash.h:54
static int* Hsh_Int3ManLookup ( Hash_IntMan_t p,
int  iData0,
int  iData1,
int  iData2 
)
inlinestatic

Definition at line 188 of file vecHash.h.

189 {
190  Hash_IntObj_t * pObj;
191  int * pPlace = Vec_IntEntryP( p->vTable, Hsh_Int3ManHash(iData0, iData1, iData2, Vec_IntSize(p->vTable)) );
192  for ( ; (pObj = Hash_IntObj(p, *pPlace)); pPlace = &pObj->iNext )
193  if ( pObj->iData0 == iData0 && pObj->iData1 == iData1 && pObj->iData2 == iData2 )
194  return pPlace;
195  assert( *pPlace == 0 );
196  return pPlace;
197 }
static int Hsh_Int3ManHash(int iData0, int iData1, int iData2, int nTableSize)
Definition: vecHash.h:184
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
typedefABC_NAMESPACE_HEADER_START struct Hash_IntObj_t_ Hash_IntObj_t
INCLUDES ///.
Definition: vecHash.h:42
static Hash_IntObj_t * Hash_IntObj(Hash_IntMan_t *p, int i)
MACRO DEFINITIONS ///.
Definition: vecHash.h:62
#define assert(ex)
Definition: util_old.h:213
static int * Vec_IntEntryP(Vec_Int_t *p, int i)
Definition: vecInt.h:417
Vec_Int_t * vTable
Definition: vecHash.h:54