#include <stdio.h>
Go to the source code of this file.
Data Structures | |
struct | Vec_Ptr_t_ |
Defines | |
#define | Vec_PtrForEachEntry(vVec, pEntry, i) for ( i = 0; (i < Vec_PtrSize(vVec)) && (((pEntry) = Vec_PtrEntry(vVec, i)), 1); i++ ) |
#define | Vec_PtrForEachEntryStart(vVec, pEntry, i, Start) for ( i = Start; (i < Vec_PtrSize(vVec)) && (((pEntry) = Vec_PtrEntry(vVec, i)), 1); i++ ) |
#define | Vec_PtrForEachEntryStop(vVec, pEntry, i, Stop) for ( i = 0; (i < Stop) && (((pEntry) = Vec_PtrEntry(vVec, i)), 1); i++ ) |
#define | Vec_PtrForEachEntryStartStop(vVec, pEntry, i, Start, Stop) for ( i = Start; (i < Stop) && (((pEntry) = Vec_PtrEntry(vVec, i)), 1); i++ ) |
#define | Vec_PtrForEachEntryReverse(vVec, pEntry, i) for ( i = Vec_PtrSize(vVec) - 1; (i >= 0) && (((pEntry) = Vec_PtrEntry(vVec, i)), 1); i-- ) |
Typedefs | |
typedef struct Vec_Ptr_t_ | Vec_Ptr_t |
Functions | |
static Vec_Ptr_t * | Vec_PtrAlloc (int nCap) |
static Vec_Ptr_t * | Vec_PtrStart (int nSize) |
static Vec_Ptr_t * | Vec_PtrAllocArray (void **pArray, int nSize) |
static Vec_Ptr_t * | Vec_PtrAllocArrayCopy (void **pArray, int nSize) |
static Vec_Ptr_t * | Vec_PtrAllocSimInfo (int nEntries, int nWords) |
static Vec_Ptr_t * | Vec_PtrAllocTruthTables (int nVars) |
static Vec_Ptr_t * | Vec_PtrDup (Vec_Ptr_t *pVec) |
static Vec_Ptr_t * | Vec_PtrDupArray (Vec_Ptr_t *pVec) |
static void | Vec_PtrFree (Vec_Ptr_t *p) |
static void ** | Vec_PtrReleaseArray (Vec_Ptr_t *p) |
static void ** | Vec_PtrArray (Vec_Ptr_t *p) |
static int | Vec_PtrSize (Vec_Ptr_t *p) |
static void * | Vec_PtrEntry (Vec_Ptr_t *p, int i) |
static void | Vec_PtrDoubleSimInfo (Vec_Ptr_t *vInfo) |
static void ** | Vec_PtrEntryP (Vec_Ptr_t *p, int i) |
static void | Vec_PtrWriteEntry (Vec_Ptr_t *p, int i, void *Entry) |
static void * | Vec_PtrEntryLast (Vec_Ptr_t *p) |
static void | Vec_PtrGrow (Vec_Ptr_t *p, int nCapMin) |
static void | Vec_PtrFill (Vec_Ptr_t *p, int nSize, void *Entry) |
static void | Vec_PtrFillExtra (Vec_Ptr_t *p, int nSize, void *Entry) |
static void * | Vec_PtrGetEntry (Vec_Ptr_t *p, int i) |
static void | Vec_PtrSetEntry (Vec_Ptr_t *p, int i, void *Entry) |
static void | Vec_PtrShrink (Vec_Ptr_t *p, int nSizeNew) |
static void | Vec_PtrClear (Vec_Ptr_t *p) |
static void | Vec_PtrCopy (Vec_Ptr_t *pDest, Vec_Ptr_t *pSour) |
static void | Vec_PtrPush (Vec_Ptr_t *p, void *Entry) |
static int | Vec_PtrPushUnique (Vec_Ptr_t *p, void *Entry) |
static void * | Vec_PtrPop (Vec_Ptr_t *p) |
static int | Vec_PtrFind (Vec_Ptr_t *p, void *Entry) |
static void | Vec_PtrRemove (Vec_Ptr_t *p, void *Entry) |
static void | Vec_PtrReorder (Vec_Ptr_t *p, int nItems) |
static void | Vec_PtrSort (Vec_Ptr_t *p, int(*Vec_PtrSortCompare)()) |
static void | Vec_PtrUniqify (Vec_Ptr_t *p, int(*Vec_PtrSortCompare)()) |
#define Vec_PtrForEachEntry | ( | vVec, | |||
pEntry, | |||||
i | ) | for ( i = 0; (i < Vec_PtrSize(vVec)) && (((pEntry) = Vec_PtrEntry(vVec, i)), 1); i++ ) |
#define Vec_PtrForEachEntryReverse | ( | vVec, | |||
pEntry, | |||||
i | ) | for ( i = Vec_PtrSize(vVec) - 1; (i >= 0) && (((pEntry) = Vec_PtrEntry(vVec, i)), 1); i-- ) |
#define Vec_PtrForEachEntryStart | ( | vVec, | |||
pEntry, | |||||
i, | |||||
Start | ) | for ( i = Start; (i < Vec_PtrSize(vVec)) && (((pEntry) = Vec_PtrEntry(vVec, i)), 1); i++ ) |
#define Vec_PtrForEachEntryStartStop | ( | vVec, | |||
pEntry, | |||||
i, | |||||
Start, | |||||
Stop | ) | for ( i = Start; (i < Stop) && (((pEntry) = Vec_PtrEntry(vVec, i)), 1); i++ ) |
#define Vec_PtrForEachEntryStop | ( | vVec, | |||
pEntry, | |||||
i, | |||||
Stop | ) | for ( i = 0; (i < Stop) && (((pEntry) = Vec_PtrEntry(vVec, i)), 1); i++ ) |
typedef struct Vec_Ptr_t_ Vec_Ptr_t |
CFile****************************************************************
FileName [vecPtr.h]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Resizable arrays.]
Synopsis [Resizable arrays of generic pointers.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [
] INCLUDES /// PARAMETERS /// BASIC TYPES ///
static Vec_Ptr_t* Vec_PtrAlloc | ( | int | nCap | ) | [inline, static] |
FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis [Allocates a vector with the given capacity.]
Description []
SideEffects []
SeeAlso []
static Vec_Ptr_t* Vec_PtrAllocArray | ( | void ** | pArray, | |
int | nSize | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Creates the vector from an integer array of the given size.]
Description []
SideEffects []
SeeAlso []
static Vec_Ptr_t* Vec_PtrAllocArrayCopy | ( | void ** | pArray, | |
int | nSize | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Creates the vector from an integer array of the given size.]
Description []
SideEffects []
SeeAlso []
static Vec_Ptr_t* Vec_PtrAllocSimInfo | ( | int | nEntries, | |
int | nWords | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Allocates the array of simulation info.]
Description [Allocates the array containing given number of entries, each of which contains given number of unsigned words of simulation data. The resulting array can be freed using regular procedure Vec_PtrFree(). It is the responsibility of the user to ensure this array is never grown.]
SideEffects []
SeeAlso []
Definition at line 166 of file vecPtr.h.
00167 { 00168 void ** pMemory; 00169 unsigned * pInfo; 00170 int i; 00171 pMemory = (void **)ALLOC( char, (sizeof(void *) + sizeof(unsigned) * nWords) * nEntries ); 00172 pInfo = (unsigned *)(pMemory + nEntries); 00173 for ( i = 0; i < nEntries; i++ ) 00174 pMemory[i] = pInfo + i * nWords; 00175 return Vec_PtrAllocArray( pMemory, nEntries ); 00176 }
static Vec_Ptr_t* Vec_PtrAllocTruthTables | ( | int | nVars | ) | [inline, static] |
Function*************************************************************
Synopsis [Allocates the array of truth tables for the given number of vars.]
Description []
SideEffects []
SeeAlso []
Definition at line 189 of file vecPtr.h.
00190 { 00191 Vec_Ptr_t * p; 00192 unsigned Masks[5] = { 0xAAAAAAAA, 0xCCCCCCCC, 0xF0F0F0F0, 0xFF00FF00, 0xFFFF0000 }; 00193 unsigned * pTruth; 00194 int i, k, nWords; 00195 nWords = (nVars <= 5 ? 1 : (1 << (nVars - 5))); 00196 p = Vec_PtrAllocSimInfo( nVars, nWords ); 00197 for ( i = 0; i < nVars; i++ ) 00198 { 00199 pTruth = (unsigned *)p->pArray[i]; 00200 if ( i < 5 ) 00201 { 00202 for ( k = 0; k < nWords; k++ ) 00203 pTruth[k] = Masks[i]; 00204 } 00205 else 00206 { 00207 for ( k = 0; k < nWords; k++ ) 00208 if ( k & (1 << (i-5)) ) 00209 pTruth[k] = ~(unsigned)0; 00210 else 00211 pTruth[k] = 0; 00212 } 00213 } 00214 return p; 00215 }
static void** Vec_PtrArray | ( | Vec_Ptr_t * | p | ) | [inline, static] |
static void Vec_PtrClear | ( | Vec_Ptr_t * | p | ) | [inline, static] |
Function*************************************************************
Synopsis [Copies the interger array.]
Description []
SideEffects []
SeeAlso []
static void Vec_PtrDoubleSimInfo | ( | Vec_Ptr_t * | vInfo | ) | [inline, static] |
Function*************************************************************
Synopsis [Resizes the array of simulation info.]
Description []
SideEffects []
SeeAlso []
Definition at line 360 of file vecPtr.h.
00361 { 00362 Vec_Ptr_t * vInfoNew; 00363 int nWords; 00364 assert( Vec_PtrSize(vInfo) > 2 ); 00365 // get the new array 00366 nWords = (unsigned *)Vec_PtrEntry(vInfo,1) - (unsigned *)Vec_PtrEntry(vInfo,0); 00367 vInfoNew = Vec_PtrAllocSimInfo( 2*Vec_PtrSize(vInfo), nWords ); 00368 // copy the simulation info 00369 memcpy( Vec_PtrEntry(vInfoNew,0), Vec_PtrEntry(vInfo,0), Vec_PtrSize(vInfo) * nWords * 4 ); 00370 // replace the array 00371 free( vInfo->pArray ); 00372 vInfo->pArray = vInfoNew->pArray; 00373 vInfo->nSize *= 2; 00374 vInfo->nCap *= 2; 00375 // free the old array 00376 vInfoNew->pArray = NULL; 00377 free( vInfoNew ); 00378 }
Function*************************************************************
Synopsis [Duplicates the integer array.]
Description []
SideEffects []
SeeAlso []
Function*************************************************************
Synopsis [Transfers the array into another vector.]
Description []
SideEffects []
SeeAlso []
static void* Vec_PtrEntry | ( | Vec_Ptr_t * | p, | |
int | i | |||
) | [inline, static] |
static void* Vec_PtrEntryLast | ( | Vec_Ptr_t * | p | ) | [inline, static] |
static void** Vec_PtrEntryP | ( | Vec_Ptr_t * | p, | |
int | i | |||
) | [inline, static] |
static void Vec_PtrFill | ( | Vec_Ptr_t * | p, | |
int | nSize, | |||
void * | Entry | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Fills the vector with given number of entries.]
Description []
SideEffects []
SeeAlso []
Definition at line 461 of file vecPtr.h.
00462 { 00463 int i; 00464 Vec_PtrGrow( p, nSize ); 00465 for ( i = 0; i < nSize; i++ ) 00466 p->pArray[i] = Entry; 00467 p->nSize = nSize; 00468 }
static void Vec_PtrFillExtra | ( | Vec_Ptr_t * | p, | |
int | nSize, | |||
void * | Entry | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Fills the vector with given number of entries.]
Description []
SideEffects []
SeeAlso []
Definition at line 481 of file vecPtr.h.
00482 { 00483 int i; 00484 if ( p->nSize >= nSize ) 00485 return; 00486 assert( p->nSize < nSize ); 00487 if ( 2 * p->nSize > nSize ) 00488 Vec_PtrGrow( p, 2 * nSize ); 00489 else 00490 Vec_PtrGrow( p, nSize ); 00491 for ( i = p->nSize; i < nSize; i++ ) 00492 p->pArray[i] = Entry; 00493 p->nSize = nSize; 00494 }
static int Vec_PtrFind | ( | Vec_Ptr_t * | p, | |
void * | Entry | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Find entry.]
Description []
SideEffects []
SeeAlso []
static void Vec_PtrFree | ( | Vec_Ptr_t * | p | ) | [inline, static] |
static void* Vec_PtrGetEntry | ( | Vec_Ptr_t * | p, | |
int | i | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Returns the entry even if the place not exist.]
Description []
SideEffects []
SeeAlso []
Definition at line 507 of file vecPtr.h.
00508 { 00509 Vec_PtrFillExtra( p, i + 1, NULL ); 00510 return Vec_PtrEntry( p, i ); 00511 }
static void Vec_PtrGrow | ( | Vec_Ptr_t * | p, | |
int | nCapMin | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Resizes the vector to the given capacity.]
Description []
SideEffects []
SeeAlso []
static void* Vec_PtrPop | ( | Vec_Ptr_t * | p | ) | [inline, static] |
static void Vec_PtrPush | ( | Vec_Ptr_t * | p, | |
void * | Entry | |||
) | [inline, static] |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 593 of file vecPtr.h.
00594 { 00595 if ( p->nSize == p->nCap ) 00596 { 00597 if ( p->nCap < 16 ) 00598 Vec_PtrGrow( p, 16 ); 00599 else 00600 Vec_PtrGrow( p, 2 * p->nCap ); 00601 } 00602 p->pArray[p->nSize++] = Entry; 00603 }
static int Vec_PtrPushUnique | ( | Vec_Ptr_t * | p, | |
void * | Entry | |||
) | [inline, static] |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 616 of file vecPtr.h.
00617 { 00618 int i; 00619 for ( i = 0; i < p->nSize; i++ ) 00620 if ( p->pArray[i] == Entry ) 00621 return 1; 00622 Vec_PtrPush( p, Entry ); 00623 return 0; 00624 }
static void** Vec_PtrReleaseArray | ( | Vec_Ptr_t * | p | ) | [inline, static] |
static void Vec_PtrRemove | ( | Vec_Ptr_t * | p, | |
void * | Entry | |||
) | [inline, static] |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 674 of file vecPtr.h.
00675 { 00676 int i; 00677 // delete assuming that it is closer to the end 00678 for ( i = p->nSize - 1; i >= 0; i-- ) 00679 if ( p->pArray[i] == Entry ) 00680 break; 00681 assert( i >= 0 ); 00682 /* 00683 // delete assuming that it is closer to the beginning 00684 for ( i = 0; i < p->nSize; i++ ) 00685 if ( p->pArray[i] == Entry ) 00686 break; 00687 assert( i < p->nSize ); 00688 */ 00689 for ( i++; i < p->nSize; i++ ) 00690 p->pArray[i-1] = p->pArray[i]; 00691 p->nSize--; 00692 }
static void Vec_PtrReorder | ( | Vec_Ptr_t * | p, | |
int | nItems | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Moves the first nItems to the end.]
Description []
SideEffects []
SeeAlso []
static void Vec_PtrSetEntry | ( | Vec_Ptr_t * | p, | |
int | i, | |||
void * | Entry | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Inserts the entry even if the place does not exist.]
Description []
SideEffects []
SeeAlso []
Definition at line 524 of file vecPtr.h.
00525 { 00526 Vec_PtrFillExtra( p, i + 1, NULL ); 00527 Vec_PtrWriteEntry( p, i, Entry ); 00528 }
static void Vec_PtrShrink | ( | Vec_Ptr_t * | p, | |
int | nSizeNew | |||
) | [inline, static] |
static int Vec_PtrSize | ( | Vec_Ptr_t * | p | ) | [inline, static] |
static void Vec_PtrSort | ( | Vec_Ptr_t * | p, | |
int(*)() | Vec_PtrSortCompare | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Sorting the entries by their integer value.]
Description []
SideEffects []
SeeAlso []
static Vec_Ptr_t* Vec_PtrStart | ( | int | nSize | ) | [inline, static] |
Function*************************************************************
Synopsis [Allocates a vector with the given size and cleans it.]
Description []
SideEffects []
SeeAlso []
Definition at line 100 of file vecPtr.h.
00101 { 00102 Vec_Ptr_t * p; 00103 p = Vec_PtrAlloc( nSize ); 00104 p->nSize = nSize; 00105 memset( p->pArray, 0, sizeof(void *) * nSize ); 00106 return p; 00107 }
static void Vec_PtrUniqify | ( | Vec_Ptr_t * | p, | |
int(*)() | Vec_PtrSortCompare | |||
) | [inline, static] |
Function*************************************************************
Synopsis [Sorting the entries by their integer value.]
Description []
SideEffects []
SeeAlso []
Definition at line 743 of file vecPtr.h.
00744 { 00745 int i, k; 00746 if ( p->nSize < 2 ) 00747 return; 00748 qsort( (void *)p->pArray, p->nSize, sizeof(void *), 00749 (int (*)(const void *, const void *)) Vec_PtrSortCompare ); 00750 for ( i = k = 1; i < p->nSize; i++ ) 00751 if ( p->pArray[i] != p->pArray[i-1] ) 00752 p->pArray[k++] = p->pArray[i]; 00753 p->nSize = k; 00754 }
static void Vec_PtrWriteEntry | ( | Vec_Ptr_t * | p, | |
int | i, | |||
void * | Entry | |||
) | [inline, static] |