21 #ifndef ABC__misc__vec__vecPtr_h
22 #define ABC__misc__vec__vecPtr_h
55 #define Vec_PtrForEachEntry( Type, vVec, pEntry, i ) \
56 for ( i = 0; (i < Vec_PtrSize(vVec)) && (((pEntry) = (Type)Vec_PtrEntry(vVec, i)), 1); i++ )
57 #define Vec_PtrForEachEntryStart( Type, vVec, pEntry, i, Start ) \
58 for ( i = Start; (i < Vec_PtrSize(vVec)) && (((pEntry) = (Type)Vec_PtrEntry(vVec, i)), 1); i++ )
59 #define Vec_PtrForEachEntryStop( Type, vVec, pEntry, i, Stop ) \
60 for ( i = 0; (i < Stop) && (((pEntry) = (Type)Vec_PtrEntry(vVec, i)), 1); i++ )
61 #define Vec_PtrForEachEntryStartStop( Type, vVec, pEntry, i, Start, Stop ) \
62 for ( i = Start; (i < Stop) && (((pEntry) = (Type)Vec_PtrEntry(vVec, i)), 1); i++ )
63 #define Vec_PtrForEachEntryReverse( Type, vVec, pEntry, i ) \
64 for ( i = Vec_PtrSize(vVec) - 1; (i >= 0) && (((pEntry) = (Type)Vec_PtrEntry(vVec, i)), 1); i-- )
65 #define Vec_PtrForEachEntryTwo( Type1, vVec1, Type2, vVec2, pEntry1, pEntry2, i ) \
66 for ( i = 0; (i < Vec_PtrSize(vVec1)) && (((pEntry1) = (Type1)Vec_PtrEntry(vVec1, i)), 1) && (((pEntry2) = (Type2)Vec_PtrEntry(vVec2, i)), 1); i++ )
87 if ( nCap > 0 && nCap < 8 )
91 p->pArray = p->nCap?
ABC_ALLOC(
void *, p->nCap ) : NULL;
111 memset( p->pArray, 0,
sizeof(
void *) * nSize );
154 memcpy( p->pArray, pArray,
sizeof(
void *) * nSize );
173 p->nSize = pVec->nSize;
174 p->nCap = pVec->nCap;
175 p->pArray = p->nCap?
ABC_ALLOC(
void *, p->nCap ) : NULL;
176 memcpy( p->pArray, pVec->pArray,
sizeof(
void *) * pVec->nSize );
183 for ( i = 0; i < p->nSize; i++ )
203 p->nSize = pVec->nSize;
204 p->nCap = pVec->nCap;
205 p->pArray = pVec->pArray;
261 void ** pArray = p->pArray;
329 return !p ? 0.0 : 1.0 *
sizeof(
void *) * p->nCap +
sizeof(
Vec_Ptr_t);
346 for ( i = 0; i < p->nSize; i++ )
347 Counter += (p->pArray[i] == NULL);
364 assert( i >= 0 && i < p->nSize );
381 assert( i >= 0 && i < p->nSize );
382 return p->pArray + i;
398 assert( i >= 0 && i < p->nSize );
399 p->pArray[i] = Entry;
416 return p->pArray[p->nSize-1];
432 if ( p->nCap >= nCapMin )
434 p->pArray =
ABC_REALLOC(
void *, p->pArray, nCapMin );
453 for ( i = 0; i < nSize; i++ )
454 p->pArray[i] = Entry;
472 if ( nSize <= p->nSize )
474 if ( nSize > 2 * p->nCap )
476 else if ( nSize > p->nCap )
478 for ( i = p->nSize; i < nSize; i++ )
530 assert( p->nSize >= nSizeNew );
564 if ( p == NULL )
return;
566 if ( pTemp != (
void *)(ABC_PTRINT_T)1 && pTemp != (
void *)(ABC_PTRINT_T)2 )
571 if ( p == NULL )
return;
591 memcpy( pDest->pArray, pSour->pArray,
sizeof(
void *) * pSour->nSize );
592 pDest->nSize = pSour->nSize;
608 if ( p->nSize == p->nCap )
615 p->pArray[p->nSize++] = Entry;
632 if ( p->nSize == p->nCap )
640 for ( i = p->nSize - 1; i >= 1; i-- )
641 p->pArray[i] = p->pArray[i-1];
642 p->pArray[0] = Entry;
659 for ( i = 0; i < p->nSize; i++ )
660 if ( p->pArray[i] == Entry )
680 return p->pArray[--p->nSize];
697 for ( i = 0; i < p->nSize; i++ )
698 if ( p->pArray[i] == Entry )
718 for ( i = p->nSize - 1; i >= 0; i-- )
719 if ( p->pArray[i] == Entry )
729 for ( i++; i < p->nSize; i++ )
730 p->pArray[i-1] = p->pArray[i];
748 assert( iHere >= 0 && iHere < p->nSize );
750 for ( i = p->nSize - 1; i > iHere; i-- )
751 p->pArray[i] = p->pArray[i-1];
752 p->pArray[i] = Entry;
768 assert( nItems < p->nSize );
770 memmove( (
char **)p->pArray + p->nSize, p->pArray, nItems *
sizeof(
void*) );
771 memmove( p->pArray, (
char **)p->pArray + nItems, p->nSize *
sizeof(
void*) );
789 for ( i = 0; i < p->nSize/2; i++ )
792 p->pArray[i] = p->pArray[p->nSize-1-i];
793 p->pArray[p->nSize-1-i] = Temp;
811 if ( p1->nSize != p2->nSize )
813 for ( i = 0; i < p1->nSize; i++ )
814 if ( p1->pArray[i] != p2->pArray[i] )
855 if ( Vec_PtrSortCompare == NULL )
856 qsort( (
void *)p->pArray, p->nSize,
sizeof(
void *),
859 qsort( (
void *)p->pArray, p->nSize,
sizeof(
void *),
860 (int (*)(
const void *,
const void *)) Vec_PtrSortCompare );
881 for ( i = k = 1; i < p->nSize; i++ )
882 if ( p->pArray[i] != p->pArray[i-1] )
883 p->pArray[k++] = p->pArray[i];
895 for ( i = k = 1; i < p->nSize; i++ )
898 p->pArray[k++] = p->pArray[i];
904 if ( Vec_PtrObjFree )
905 Vec_PtrObjFree( p->pArray[i] );
934 pMemory = (
void **)
ABC_ALLOC(
char, (
sizeof(
void *) +
sizeof(
unsigned) * nWords) * nEntries );
935 pInfo = (
unsigned *)(pMemory + nEntries);
936 for ( i = 0; i < nEntries; i++ )
937 pMemory[i] = pInfo + i * nWords;
971 for ( i = 0; i < vInfo->nSize; i++ )
989 for ( i = 0; i < vInfo->nSize; i++ )
1016 vInfo->pArray = vInfoNew->pArray;
1020 vInfoNew->pArray = NULL;
1044 for ( i = 0; i < vInfo->nSize; i++ )
1048 vInfo->pArray = vInfoNew->pArray;
1050 vInfoNew->pArray = NULL;
1068 unsigned Masks[5] = { 0xAAAAAAAA, 0xCCCCCCCC, 0xF0F0F0F0, 0xFF00FF00, 0xFFFF0000 };
1071 nWords = (nVars <= 5 ? 1 : (1 << (nVars - 5)));
1073 for ( i = 0; i < nVars; i++ )
1075 pTruth = (
unsigned *)p->pArray[i];
1078 for ( k = 0; k <
nWords; k++ )
1079 pTruth[k] = Masks[i];
1083 for ( k = 0; k <
nWords; k++ )
1084 if ( k & (1 << (i-5)) )
1085 pTruth[k] = ~(
unsigned)0;
static void Vec_PtrReverseOrder(Vec_Ptr_t *p)
static Vec_Ptr_t * Vec_PtrStart(int nSize)
static int Vec_PtrSortComparePtr(void **pp1, void **pp2)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
static void ** Vec_PtrEntryP(Vec_Ptr_t *p, int i)
static void Vec_PtrSetEntry(Vec_Ptr_t *p, int i, void *Entry)
static void Vec_PtrCopy(Vec_Ptr_t *pDest, Vec_Ptr_t *pSour)
static int Vec_PtrSortCompare(void **pp1, void **pp2)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
static void Vec_PtrFill(Vec_Ptr_t *p, int nSize, void *Entry)
static int Vec_PtrPushUnique(Vec_Ptr_t *p, void *Entry)
static void Vec_PtrInsert(Vec_Ptr_t *p, int iHere, void *Entry)
#define ABC_REALLOC(type, obj, num)
static void Vec_PtrGrow(Vec_Ptr_t *p, int nCapMin)
static void Vec_PtrDoubleSimInfo(Vec_Ptr_t *vInfo)
static Vec_Ptr_t * Vec_PtrAllocArrayCopy(void **pArray, int nSize)
static void Vec_PtrFreeFree(Vec_Ptr_t *p)
static void Vec_PtrFillExtra(Vec_Ptr_t *p, int nSize, void *Fill)
static void Vec_PtrCleanSimInfo(Vec_Ptr_t *vInfo, int iWord, int nWords)
static void Vec_PtrSort(Vec_Ptr_t *p, int(*Vec_PtrSortCompare)()) ___unused
static void * Vec_PtrGetEntry(Vec_Ptr_t *p, int i)
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
#define ABC_ALLOC(type, num)
static Vec_Ptr_t * Vec_PtrDup(Vec_Ptr_t *pVec)
static void Vec_PtrFillSimInfo(Vec_Ptr_t *vInfo, int iWord, int nWords)
static int Vec_PtrSize(Vec_Ptr_t *p)
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_PtrUniqify(Vec_Ptr_t *p, int(*Vec_PtrSortCompare)()) ___unused
static Vec_Ptr_t * Vec_PtrAllocTruthTables(int nVars)
static void Vec_PtrPushFirst(Vec_Ptr_t *p, void *Entry)
static void * Vec_PtrEntryLast(Vec_Ptr_t *p)
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
static double Vec_PtrMemory(Vec_Ptr_t *p)
#define ABC_NAMESPACE_HEADER_END
static int Vec_PtrCountZero(Vec_Ptr_t *p)
static int Vec_PtrCap(Vec_Ptr_t *p)
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
static Vec_Ptr_t * Vec_PtrDupArray(Vec_Ptr_t *pVec)
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
static int Vec_PtrReadWordsSimInfo(Vec_Ptr_t *p)
static int Vec_IntSize(Vec_Int_t *p)
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static Vec_Ptr_t * Vec_PtrAllocArray(void **pArray, int nSize)
static void Vec_PtrFreeP(Vec_Ptr_t **p)
static void Vec_PtrReallocSimInfo(Vec_Ptr_t *vInfo)
static void Vec_PtrClear(Vec_Ptr_t *p)
static int Vec_PtrEqual(Vec_Ptr_t *p1, Vec_Ptr_t *p2)
static void Vec_PtrReorder(Vec_Ptr_t *p, int nItems)
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
static void Vec_PtrShrink(Vec_Ptr_t *p, int nSizeNew)
char * Abc_UtilStrsav(char *s)
static Vec_Ptr_t * Vec_PtrDupStr(Vec_Ptr_t *pVec)
static void ** Vec_PtrArray(Vec_Ptr_t *p)
static void Vec_PtrFreeData(Vec_Ptr_t *p)
static Vec_Ptr_t * Vec_PtrAllocSimInfo(int nEntries, int nWords)
static void Vec_PtrUniqify2(Vec_Ptr_t *p, int(*Vec_PtrSortCompare)(void **, void **), void(*Vec_PtrObjFree)(void *), Vec_Int_t *vCounts) ___unused
static void Vec_PtrFree(Vec_Ptr_t *p)
static void ** Vec_PtrReleaseArray(Vec_Ptr_t *p)