#include <stdio.h>
Go to the source code of this file.
|
#define | Vec_BitForEachEntry(vVec, Entry, i) for ( i = 0; (i < Vec_BitSize(vVec)) && (((Entry) = Vec_BitEntry(vVec, i)), 1); i++ ) |
| MACRO DEFINITIONS ///. More...
|
|
#define | Vec_BitForEachEntryStart(vVec, Entry, i, Start) for ( i = Start; (i < Vec_BitSize(vVec)) && (((Entry) = Vec_BitEntry(vVec, i)), 1); i++ ) |
|
#define | Vec_BitForEachEntryStop(vVec, Entry, i, Stop) for ( i = 0; (i < Stop) && (((Entry) = Vec_BitEntry(vVec, i)), 1); i++ ) |
|
#define | Vec_BitForEachEntryStartStop(vVec, Entry, i, Start, Stop) for ( i = Start; (i < Stop) && (((Entry) = Vec_BitEntry(vVec, i)), 1); i++ ) |
|
#define | Vec_BitForEachEntryReverse(vVec, pEntry, i) for ( i = Vec_BitSize(vVec) - 1; (i >= 0) && (((pEntry) = Vec_BitEntry(vVec, i)), 1); i-- ) |
|
|
static Vec_Bit_t * | Vec_BitAlloc (int nCap) |
| FUNCTION DEFINITIONS ///. More...
|
|
static Vec_Bit_t * | Vec_BitStart (int nSize) |
|
static Vec_Bit_t * | Vec_BitStartFull (int nSize) |
|
static Vec_Bit_t * | Vec_BitDup (Vec_Bit_t *pVec) |
|
static void | Vec_BitFree (Vec_Bit_t *p) |
|
static void | Vec_BitFreeP (Vec_Bit_t **p) |
|
static int * | Vec_BitReleaseArray (Vec_Bit_t *p) |
|
static int * | Vec_BitArray (Vec_Bit_t *p) |
|
static int | Vec_BitSize (Vec_Bit_t *p) |
|
static int | Vec_BitCap (Vec_Bit_t *p) |
|
static double | Vec_BitMemory (Vec_Bit_t *p) |
|
static int | Vec_BitEntry (Vec_Bit_t *p, int i) |
|
static void | Vec_BitWriteEntry (Vec_Bit_t *p, int i, int Entry) |
|
static int | Vec_BitEntryLast (Vec_Bit_t *p) |
|
static void | Vec_BitGrow (Vec_Bit_t *p, int nCapMin) |
|
static void | Vec_BitFill (Vec_Bit_t *p, int nSize, int Fill) |
|
static void | Vec_BitFillExtra (Vec_Bit_t *p, int nSize, int Fill) |
|
static int | Vec_BitGetEntry (Vec_Bit_t *p, int i) |
|
static void | Vec_BitSetEntry (Vec_Bit_t *p, int i, int Entry) |
|
static void | Vec_BitShrink (Vec_Bit_t *p, int nSizeNew) |
|
static void | Vec_BitClear (Vec_Bit_t *p) |
|
static void | Vec_BitPush (Vec_Bit_t *p, int Entry) |
|
static int | Vec_BitPop (Vec_Bit_t *p) |
|
static int | Vec_BitCountWord (unsigned uWord) |
|
static int | Vec_BitCount (Vec_Bit_t *p) |
|
#define Vec_BitForEachEntry |
( |
|
vVec, |
|
|
|
Entry, |
|
|
|
i |
|
) |
| for ( i = 0; (i < Vec_BitSize(vVec)) && (((Entry) = Vec_BitEntry(vVec, i)), 1); i++ ) |
MACRO DEFINITIONS ///.
Definition at line 54 of file vecBit.h.
#define Vec_BitForEachEntryReverse |
( |
|
vVec, |
|
|
|
pEntry, |
|
|
|
i |
|
) |
| for ( i = Vec_BitSize(vVec) - 1; (i >= 0) && (((pEntry) = Vec_BitEntry(vVec, i)), 1); i-- ) |
#define Vec_BitForEachEntryStart |
( |
|
vVec, |
|
|
|
Entry, |
|
|
|
i, |
|
|
|
Start |
|
) |
| for ( i = Start; (i < Vec_BitSize(vVec)) && (((Entry) = Vec_BitEntry(vVec, i)), 1); i++ ) |
#define Vec_BitForEachEntryStartStop |
( |
|
vVec, |
|
|
|
Entry, |
|
|
|
i, |
|
|
|
Start, |
|
|
|
Stop |
|
) |
| for ( i = Start; (i < Stop) && (((Entry) = Vec_BitEntry(vVec, i)), 1); i++ ) |
#define Vec_BitForEachEntryStop |
( |
|
vVec, |
|
|
|
Entry, |
|
|
|
i, |
|
|
|
Stop |
|
) |
| for ( i = 0; (i < Stop) && (((Entry) = Vec_BitEntry(vVec, i)), 1); i++ ) |
INCLUDES ///.
CFile****************************************************************
FileName [vecBit.h]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Resizable arrays.]
Synopsis [Resizable arrays of bits.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [
- Id:
- vecBit.h,v 1.00 2005/06/20 00:00:00 alanmi Exp
]PARAMETERS ///BASIC TYPES ///
Definition at line 42 of file vecBit.h.
FUNCTION DEFINITIONS ///.
Function*************************************************************
Synopsis [Allocates a vector with the given capacity.]
Description []
SideEffects []
SeeAlso []
Definition at line 80 of file vecBit.h.
83 nCap = (nCap >> 5) + ((nCap & 31) > 0);
87 p->pArray = nCap?
ABC_ALLOC(
int, nCap ) : NULL;
#define ABC_ALLOC(type, num)
typedefABC_NAMESPACE_HEADER_START struct Vec_Bit_t_ Vec_Bit_t
INCLUDES ///.
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 223 of file vecBit.h.
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 255 of file vecBit.h.
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 500 of file vecBit.h.
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 584 of file vecBit.h.
586 unsigned * pArray = (
unsigned *)
p->pArray;
587 int nWords = (
p->nSize >> 5) + ((
p->nSize & 31) > 0);
592 for ( i = 0; i <
nWords-1; i++ )
598 for ( i = 0; i <
nWords; i++ )
static int Vec_BitCountWord(unsigned uWord)
static int Vec_BitCountWord |
( |
unsigned |
uWord | ) |
|
|
inlinestatic |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 564 of file vecBit.h.
566 uWord = (uWord & 0x55555555) + ((uWord>>1) & 0x55555555);
567 uWord = (uWord & 0x33333333) + ((uWord>>2) & 0x33333333);
568 uWord = (uWord & 0x0F0F0F0F) + ((uWord>>4) & 0x0F0F0F0F);
569 uWord = (uWord & 0x00FF00FF) + ((uWord>>8) & 0x00FF00FF);
570 return (uWord & 0x0000FFFF) + (uWord>>16);
Function*************************************************************
Synopsis [Duplicates the integer array.]
Description []
SideEffects []
SeeAlso []
Definition at line 144 of file vecBit.h.
147 assert( (pVec->nSize & 31) == 0 );
149 p->nSize = pVec->nSize;
150 p->nCap = pVec->nSize;
151 p->pArray = p->nCap?
ABC_ALLOC(
int, p->nCap >> 5 ) : NULL;
152 memcpy( p->pArray, pVec->pArray,
sizeof(
int) * (p->nCap >> 5) );
#define ABC_ALLOC(type, num)
typedefABC_NAMESPACE_HEADER_START struct Vec_Bit_t_ Vec_Bit_t
INCLUDES ///.
static int Vec_BitEntry |
( |
Vec_Bit_t * |
p, |
|
|
int |
i |
|
) |
| |
|
inlinestatic |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 287 of file vecBit.h.
289 assert( i >= 0 && i < p->nSize );
290 return (
p->pArray[i >> 5] >> (i & 31)) & 1;
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 325 of file vecBit.h.
static int Vec_BitEntry(Vec_Bit_t *p, int i)
static void Vec_BitFill |
( |
Vec_Bit_t * |
p, |
|
|
int |
nSize, |
|
|
int |
Fill |
|
) |
| |
|
inlinestatic |
Function*************************************************************
Synopsis [Fills the vector with given number of entries.]
Description []
SideEffects []
SeeAlso []
Definition at line 363 of file vecBit.h.
367 nSize = (nSize >> 5) + ((nSize & 31) > 0);
370 for ( i = 0; i < nSize; i++ )
373 else if ( Fill == 1 )
375 for ( i = 0; i < nSize; i++ )
379 p->nSize = nSize * 32;
static void Vec_BitGrow(Vec_Bit_t *p, int nCapMin)
static void Vec_BitFillExtra |
( |
Vec_Bit_t * |
p, |
|
|
int |
nSize, |
|
|
int |
Fill |
|
) |
| |
|
inlinestatic |
Function*************************************************************
Synopsis [Fills the vector with given number of entries.]
Description []
SideEffects []
SeeAlso []
Definition at line 393 of file vecBit.h.
396 if ( nSize <= p->nSize )
398 if ( nSize > 2 *
p->nCap )
400 else if ( nSize >
p->nCap )
404 if ( (
p->nSize >> 5) == (nSize >> 5) )
406 unsigned Mask = (~(~0 << (nSize-
p->nSize)) <<
p->nSize);
408 p->pArray[nSize >> 5] |= Mask;
409 else if ( Fill == 0 )
410 p->pArray[nSize >> 5] &= ~Mask;
415 unsigned Mask1 = (
p->nSize & 31) ? ~0 << (
p->nSize & 31) : 0;
416 unsigned Mask2 = (nSize & 31) ? ~(~0 << (nSize & 31)) : 0;
417 int w1 = (
p->nSize >> 5);
418 int w2 = (nSize >> 5);
421 p->pArray[w1] |= Mask1;
422 p->pArray[w2] |= Mask2;
423 for ( i = w1 + 1; i < w2; i++ )
426 else if ( Fill == 0 )
428 p->pArray[w1] &= ~Mask1;
429 p->pArray[w2] &= ~Mask2;
430 for ( i = w1 + 1; i < w2; i++ )
static void Vec_BitGrow(Vec_Bit_t *p, int nCapMin)
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 167 of file vecBit.h.
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 184 of file vecBit.h.
static int Vec_BitGetEntry |
( |
Vec_Bit_t * |
p, |
|
|
int |
i |
|
) |
| |
|
inlinestatic |
Function*************************************************************
Synopsis [Returns the entry even if the place not exist.]
Description []
SideEffects []
SeeAlso []
Definition at line 449 of file vecBit.h.
static void Vec_BitFillExtra(Vec_Bit_t *p, int nSize, int Fill)
static int Vec_BitEntry(Vec_Bit_t *p, int i)
static void Vec_BitGrow |
( |
Vec_Bit_t * |
p, |
|
|
int |
nCapMin |
|
) |
| |
|
inlinestatic |
Function*************************************************************
Synopsis [Resizes the vector to the given capacity.]
Description []
SideEffects []
SeeAlso []
Definition at line 342 of file vecBit.h.
344 if (
p->nCap >= nCapMin )
346 nCapMin = (nCapMin >> 5) + ((nCapMin & 31) > 0);
349 p->nCap = nCapMin * 32;
#define ABC_REALLOC(type, obj, num)
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 271 of file vecBit.h.
273 return !
p ? 0.0 : 1.0 *
sizeof(int) *
p->nCap +
sizeof(
Vec_Bit_t);
typedefABC_NAMESPACE_HEADER_START struct Vec_Bit_t_ Vec_Bit_t
INCLUDES ///.
Function*************************************************************
Synopsis [Returns the last entry and removes it from the list.]
Description []
SideEffects []
SeeAlso []
Definition at line 544 of file vecBit.h.
static int Vec_BitEntryLast(Vec_Bit_t *p)
static void Vec_BitPush |
( |
Vec_Bit_t * |
p, |
|
|
int |
Entry |
|
) |
| |
|
inlinestatic |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 516 of file vecBit.h.
518 if (
p->nSize ==
p->nCap )
526 p->pArray[
p->nSize >> 5] |= (1 << (
p->nSize & 31));
527 else if ( Entry == 0 )
528 p->pArray[
p->nSize >> 5] &= ~(1 << (
p->nSize & 31));
static void Vec_BitGrow(Vec_Bit_t *p, int nCapMin)
static int* Vec_BitReleaseArray |
( |
Vec_Bit_t * |
p | ) |
|
|
inlinestatic |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 203 of file vecBit.h.
205 int * pArray =
p->pArray;
static void Vec_BitSetEntry |
( |
Vec_Bit_t * |
p, |
|
|
int |
i, |
|
|
int |
Entry |
|
) |
| |
|
inlinestatic |
Function*************************************************************
Synopsis [Inserts the entry even if the place does not exist.]
Description []
SideEffects []
SeeAlso []
Definition at line 466 of file vecBit.h.
static void Vec_BitWriteEntry(Vec_Bit_t *p, int i, int Entry)
static void Vec_BitFillExtra(Vec_Bit_t *p, int nSize, int Fill)
static void Vec_BitShrink |
( |
Vec_Bit_t * |
p, |
|
|
int |
nSizeNew |
|
) |
| |
|
inlinestatic |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 483 of file vecBit.h.
485 assert(
p->nSize >= nSizeNew );
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 239 of file vecBit.h.
Function*************************************************************
Synopsis [Allocates a vector with the given size and cleans it.]
Description []
SideEffects []
SeeAlso []
Definition at line 102 of file vecBit.h.
105 nSize = (nSize >> 5) + ((nSize & 31) > 0);
107 p->nSize = nSize * 32;
108 memset( p->pArray, 0,
sizeof(
int) * nSize );
typedefABC_NAMESPACE_HEADER_START struct Vec_Bit_t_ Vec_Bit_t
INCLUDES ///.
static Vec_Bit_t * Vec_BitAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static Vec_Bit_t* Vec_BitStartFull |
( |
int |
nSize | ) |
|
|
inlinestatic |
Function*************************************************************
Synopsis [Allocates a vector with the given size and cleans it.]
Description []
SideEffects []
SeeAlso []
Definition at line 123 of file vecBit.h.
126 nSize = (nSize >> 5) + ((nSize & 31) > 0);
128 p->nSize = nSize * 32;
129 memset( p->pArray, 0xff,
sizeof(
int) * nSize );
typedefABC_NAMESPACE_HEADER_START struct Vec_Bit_t_ Vec_Bit_t
INCLUDES ///.
static Vec_Bit_t * Vec_BitAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static void Vec_BitWriteEntry |
( |
Vec_Bit_t * |
p, |
|
|
int |
i, |
|
|
int |
Entry |
|
) |
| |
|
inlinestatic |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 304 of file vecBit.h.
306 assert( i >= 0 && i < p->nSize );
308 p->pArray[i >> 5] |= (1 << (i & 31));
309 else if ( Entry == 0 )
310 p->pArray[i >> 5] &= ~(1 << (i & 31));