21 #ifndef ABC__misc__vec__vecWrd_h
22 #define ABC__misc__vec__vecWrd_h
54 #define Vec_WrdForEachEntry( vVec, Entry, i ) \
55 for ( i = 0; (i < Vec_WrdSize(vVec)) && (((Entry) = Vec_WrdEntry(vVec, i)), 1); i++ )
56 #define Vec_WrdForEachEntryStart( vVec, Entry, i, Start ) \
57 for ( i = Start; (i < Vec_WrdSize(vVec)) && (((Entry) = Vec_WrdEntry(vVec, i)), 1); i++ )
58 #define Vec_WrdForEachEntryStop( vVec, Entry, i, Stop ) \
59 for ( i = 0; (i < Stop) && (((Entry) = Vec_WrdEntry(vVec, i)), 1); i++ )
60 #define Vec_WrdForEachEntryStartStop( vVec, Entry, i, Start, Stop ) \
61 for ( i = Start; (i < Stop) && (((Entry) = Vec_WrdEntry(vVec, i)), 1); i++ )
62 #define Vec_WrdForEachEntryReverse( vVec, pEntry, i ) \
63 for ( i = Vec_WrdSize(vVec) - 1; (i >= 0) && (((pEntry) = Vec_WrdEntry(vVec, i)), 1); i-- )
84 if ( nCap > 0 && nCap < 16 )
128 memset( p->pArray, 0xff,
sizeof(
word) * nSize );
149 for ( i = 0; i < nSize; i++ )
193 memcpy( p->pArray, pArray,
sizeof(
word) * nSize );
212 p->nSize = pVec->nSize;
213 p->nCap = pVec->nSize;
215 memcpy( p->pArray, pVec->pArray,
sizeof(
word) * pVec->nSize );
234 p->nSize = pVec->nSize;
235 p->nCap = pVec->nCap;
236 p->pArray = pVec->pArray;
298 word * pArray = p->pArray;
322 return p->pArray + p->nSize;
370 return !p ? 0.0 : 1.0 *
sizeof(
word) * p->nCap +
sizeof(
Vec_Wrd_t);
386 assert( i >= 0 && i < p->nSize );
403 assert( i >= 0 && i < p->nSize );
404 return p->pArray + i;
420 assert( i >= 0 && i < p->nSize );
421 p->pArray[i] = Entry;
437 assert( i >= 0 && i < p->nSize );
438 return p->pArray[i] += Addition;
455 return p->pArray[p->nSize-1];
471 if ( p->nCap >= nCapMin )
493 for ( i = 0; i < nSize; i++ )
512 if ( nSize <= p->nSize )
514 if ( nSize > 2 * p->nCap )
516 else if ( nSize > p->nCap )
518 for ( i = p->nSize; i < nSize; i++ )
587 assert( p->nSize >= nSizeNew );
620 if ( p->nSize == p->nCap )
627 p->pArray[p->nSize++] = Entry;
644 if ( p->nSize == p->nCap )
652 for ( i = p->nSize - 1; i >= 1; i-- )
653 p->pArray[i] = p->pArray[i-1];
654 p->pArray[0] = Entry;
671 if ( p->nSize == p->nCap )
679 for ( i = p->nSize-2; i >= 0; i-- )
680 if ( p->pArray[i] > Entry )
681 p->pArray[i+1] = p->pArray[i];
684 p->pArray[i+1] = Entry;
701 for ( i = 0; i < p->nSize; i++ )
702 if ( p->pArray[i] == Entry )
722 for ( i = 0; i < p->nSize; i++ )
723 if ( p->pArray[i] == Entry )
746 if ( p->nSize > p->nCap )
751 return p->pArray + p->nSize -
nWords;
768 return p->pArray[--p->nSize];
785 for ( i = 0; i < p->nSize; i++ )
786 if ( p->pArray[i] == Entry )
805 for ( i = 0; i < p->nSize; i++ )
806 if ( p->pArray[i] == Entry )
811 for ( i++; i < p->nSize; i++ )
812 p->pArray[i-1] = p->pArray[i];
831 assert( iHere >= 0 && iHere < p->nSize );
833 for ( i = p->nSize - 1; i > iHere; i-- )
834 p->pArray[i] = p->pArray[i-1];
835 p->pArray[i] = Entry;
856 for ( i = 1; i < p->nSize; i++ )
857 if ( Best < p->pArray[i] )
880 for ( i = 1; i < p->nSize; i++ )
881 if ( Best > p->pArray[i] )
901 for ( i = 0; i < p->nSize/2; i++ )
904 p->pArray[i] = p->pArray[p->nSize-1-i];
905 p->pArray[p->nSize-1-i] = Temp;
947 for ( i = 0; i < p->nSize; i++ )
948 Counter += p->pArray[i];
966 if ( p1->nSize != p2->nSize )
968 for ( i = 0; i < p1->nSize; i++ )
969 if ( p1->pArray[i] != p2->pArray[i] )
991 vTemp = p1, p1 = p2, p2 = vTemp;
1058 qsort( (
void *)p->pArray, p->nSize,
sizeof(
word),
1061 qsort( (
void *)p->pArray, p->nSize,
sizeof(
word),
1082 for ( i = k = 1; i < p->nSize; i++ )
1083 if ( p->pArray[i] != p->pArray[i-1] )
1084 p->pArray[k++] = p->pArray[i];
1091 vDataInt->nSize *= 2;
1092 vDataInt->nCap *= 2;
1094 vDataInt->nSize /= 2;
1095 vDataInt->nCap /= 2;
1102 vDataInt->nSize *= 2;
1103 vDataInt->nCap *= 2;
1105 vDataInt->nSize /= 2;
1106 vDataInt->nCap /= 2;
1107 vResInt->nSize /= 2;
1145 qsort( (
void *)p->pArray, p->nSize,
sizeof(
word),
static void Vec_WrdGrow(Vec_Wrd_t *p, int nCapMin)
static Vec_Wrd_t * Vec_WrdDupArray(Vec_Wrd_t *pVec)
static word Vec_WrdFindMax(Vec_Wrd_t *p)
static int Vec_WrdEqual(Vec_Wrd_t *p1, Vec_Wrd_t *p2)
static double Vec_WrdMemory(Vec_Wrd_t *p)
static void Vec_WrdSortUnsigned(Vec_Wrd_t *p)
static word * Vec_WrdGetEntryP(Vec_Wrd_t *p, int i)
static int Vec_WrdSortCompareUnsigned(word *pp1, word *pp2)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
static int Vec_WrdCountCommon(Vec_Wrd_t *p1, Vec_Wrd_t *p2)
#define ABC_REALLOC(type, obj, num)
static void Vec_WrdPush(Vec_Wrd_t *p, word Entry)
static word * Vec_WrdFetch(Vec_Wrd_t *p, int nWords)
static int Vec_WrdPushUnique(Vec_Wrd_t *p, word Entry)
static void Vec_WrdPushOrder(Vec_Wrd_t *p, word Entry)
static int Vec_WrdCap(Vec_Wrd_t *p)
static int Vec_WrdPushUniqueOrder(Vec_Wrd_t *p, word Entry)
#define ABC_ALLOC(type, num)
static word Vec_WrdEntryLast(Vec_Wrd_t *p)
static void Vec_WrdInsert(Vec_Wrd_t *p, int iHere, word Entry)
static void Vec_WrdReverseOrder(Vec_Wrd_t *p)
static int Vec_WrdSize(Vec_Wrd_t *p)
static void Vec_WrdFreeP(Vec_Wrd_t **p)
#define Vec_WrdForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
static void Vec_WrdPushFirst(Vec_Wrd_t *p, word Entry)
static int Vec_WrdSortCompare1(word *pp1, word *pp2)
static word Vec_WrdSum(Vec_Wrd_t *p)
static void Vec_WrdUniqify(Vec_Wrd_t *p)
static word Vec_WrdAddToEntry(Vec_Wrd_t *p, int i, word Addition)
static word Vec_WrdFindMin(Vec_Wrd_t *p)
static Vec_Wrd_t * Vec_WrdUniqifyHash(Vec_Wrd_t *vData, int nWordSize)
static void Vec_WrdSetEntry(Vec_Wrd_t *p, int i, word Entry)
static void Vec_WrdClear(Vec_Wrd_t *p)
static void Vec_WrdShrink(Vec_Wrd_t *p, int nSizeNew)
static void Vec_WrdWriteEntry(Vec_Wrd_t *p, int i, word Entry)
static void Vec_WrdFill(Vec_Wrd_t *p, int nSize, word Fill)
static word * Vec_WrdLimit(Vec_Wrd_t *p)
unsigned __int64 word
DECLARATIONS ///.
static Vec_Wrd_t * Vec_WrdInvert(Vec_Wrd_t *p, word Fill)
static void Vec_WrdFree(Vec_Wrd_t *p)
static Vec_Wrd_t * Vec_WrdStartFull(int nSize)
static Vec_Wrd_t * Vec_WrdStartNatural(int nSize)
static word Vec_WrdGetEntry(Vec_Wrd_t *p, int i)
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
#define ABC_NAMESPACE_HEADER_END
static Vec_Wrd_t * Vec_WrdAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static int Vec_WrdFind(Vec_Wrd_t *p, word Entry)
static Vec_Wrd_t * Vec_WrdStart(int nSize)
static Vec_Int_t * Vec_IntUniqifyHash(Vec_Int_t *vData, int nIntSize)
static void Vec_WrdSort(Vec_Wrd_t *p, int fReverse)
static word * Vec_WrdArray(Vec_Wrd_t *p)
static word * Vec_WrdReleaseArray(Vec_Wrd_t *p)
static int Vec_WrdRemove(Vec_Wrd_t *p, word Entry)
static word Vec_WrdEntry(Vec_Wrd_t *p, int i)
static word Vec_WrdPop(Vec_Wrd_t *p)
static int Vec_WrdSortCompare2(word *pp1, word *pp2)
static Vec_Wrd_t * Vec_WrdAllocArrayCopy(word *pArray, int nSize)
static int Vec_IntUniqueCount(Vec_Int_t *vData, int nIntSize, Vec_Int_t **pvMap)
static void Vec_WrdAppend(Vec_Wrd_t *vVec1, Vec_Wrd_t *vVec2)
static void Vec_WrdFillExtra(Vec_Wrd_t *p, int nSize, word Fill)
static Vec_Wrd_t * Vec_WrdDup(Vec_Wrd_t *pVec)
static int Vec_WrdUniqueCount(Vec_Wrd_t *vData, int nWordSize, Vec_Int_t **pvMap)
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
static Vec_Wrd_t * Vec_WrdAllocArray(word *pArray, int nSize)
static void Vec_WrdErase(Vec_Wrd_t *p)
static word * Vec_WrdEntryP(Vec_Wrd_t *p, int i)