21 #ifndef ABC__misc__vec__vecVec_h
22 #define ABC__misc__vec__vecVec_h
55 #define Vec_VecForEachLevel( vGlob, vVec, i ) \
56 for ( i = 0; (i < Vec_VecSize(vGlob)) && (((vVec) = Vec_VecEntry(vGlob, i)), 1); i++ )
57 #define Vec_VecForEachLevelStart( vGlob, vVec, i, LevelStart ) \
58 for ( i = LevelStart; (i < Vec_VecSize(vGlob)) && (((vVec) = Vec_VecEntry(vGlob, i)), 1); i++ )
59 #define Vec_VecForEachLevelStop( vGlob, vVec, i, LevelStop ) \
60 for ( i = 0; (i < LevelStop) && (((vVec) = Vec_VecEntry(vGlob, i)), 1); i++ )
61 #define Vec_VecForEachLevelStartStop( vGlob, vVec, i, LevelStart, LevelStop ) \
62 for ( i = LevelStart; (i < LevelStop) && (((vVec) = Vec_VecEntry(vGlob, i)), 1); i++ )
63 #define Vec_VecForEachLevelReverse( vGlob, vVec, i ) \
64 for ( i = Vec_VecSize(vGlob)-1; (i >= 0) && (((vVec) = Vec_VecEntry(vGlob, i)), 1); i-- )
65 #define Vec_VecForEachLevelReverseStartStop( vGlob, vVec, i, LevelStart, LevelStop ) \
66 for ( i = LevelStart-1; (i >= LevelStop) && (((vVec) = Vec_VecEntry(vGlob, i)), 1); i-- )
67 #define Vec_VecForEachLevelTwo( vGlob1, vGlob2, vVec1, vVec2, i ) \
68 for ( i = 0; (i < Vec_VecSize(vGlob1)) && (((vVec1) = Vec_VecEntry(vGlob1, i)), 1) && (((vVec2) = Vec_VecEntry(vGlob2, i)), 1); i++ )
71 #define Vec_VecForEachLevelInt( vGlob, vVec, i ) \
72 for ( i = 0; (i < Vec_VecSize(vGlob)) && (((vVec) = Vec_VecEntryInt(vGlob, i)), 1); i++ )
73 #define Vec_VecForEachLevelIntStart( vGlob, vVec, i, LevelStart ) \
74 for ( i = LevelStart; (i < Vec_VecSize(vGlob)) && (((vVec) = Vec_VecEntryInt(vGlob, i)), 1); i++ )
75 #define Vec_VecForEachLevelIntStop( vGlob, vVec, i, LevelStop ) \
76 for ( i = 0; (i < LevelStop) && (((vVec) = Vec_VecEntryInt(vGlob, i)), 1); i++ )
77 #define Vec_VecForEachLevelIntStartStop( vGlob, vVec, i, LevelStart, LevelStop ) \
78 for ( i = LevelStart; (i < LevelStop) && (((vVec) = Vec_VecEntryInt(vGlob, i)), 1); i++ )
79 #define Vec_VecForEachLevelIntReverse( vGlob, vVec, i ) \
80 for ( i = Vec_VecSize(vGlob)-1; (i >= 0) && (((vVec) = Vec_VecEntryInt(vGlob, i)), 1); i-- )
81 #define Vec_VecForEachLevelIntReverseStartStop( vGlob, vVec, i, LevelStart, LevelStop ) \
82 for ( i = LevelStart-1; (i >= LevelStop) && (((vVec) = Vec_VecEntryInt(vGlob, i)), 1); i-- )
83 #define Vec_VecForEachLevelIntTwo( vGlob1, vGlob2, vVec1, vVec2, i ) \
84 for ( i = 0; (i < Vec_VecSize(vGlob1)) && (((vVec1) = Vec_VecEntryInt(vGlob1, i)), 1) && (((vVec2) = Vec_VecEntryInt(vGlob2, i)), 1); i++ )
87 #define Vec_VecForEachEntry( Type, vGlob, pEntry, i, k ) \
88 for ( i = 0; i < Vec_VecSize(vGlob); i++ ) \
89 Vec_PtrForEachEntry( Type, Vec_VecEntry(vGlob, i), pEntry, k )
90 #define Vec_VecForEachEntryLevel( Type, vGlob, pEntry, i, Level ) \
91 Vec_PtrForEachEntry( Type, Vec_VecEntry(vGlob, Level), pEntry, i )
92 #define Vec_VecForEachEntryStart( Type, vGlob, pEntry, i, k, LevelStart ) \
93 for ( i = LevelStart; i < Vec_VecSize(vGlob); i++ ) \
94 Vec_PtrForEachEntry( Type, Vec_VecEntry(vGlob, i), pEntry, k )
95 #define Vec_VecForEachEntryStartStop( Type, vGlob, pEntry, i, k, LevelStart, LevelStop ) \
96 for ( i = LevelStart; i < LevelStop; i++ ) \
97 Vec_PtrForEachEntry( Type, Vec_VecEntry(vGlob, i), pEntry, k )
98 #define Vec_VecForEachEntryReverse( Type, vGlob, pEntry, i, k ) \
99 for ( i = 0; i < Vec_VecSize(vGlob); i++ ) \
100 Vec_PtrForEachEntryReverse( Type, Vec_VecEntry(vGlob, i), pEntry, k )
101 #define Vec_VecForEachEntryReverseReverse( Type, vGlob, pEntry, i, k ) \
102 for ( i = Vec_VecSize(vGlob) - 1; i >= 0; i-- ) \
103 Vec_PtrForEachEntryReverse( Type, Vec_VecEntry(vGlob, i), pEntry, k )
104 #define Vec_VecForEachEntryReverseStart( Type, vGlob, pEntry, i, k, LevelStart ) \
105 for ( i = LevelStart-1; i >= 0; i-- ) \
106 Vec_PtrForEachEntry( Type, Vec_VecEntry(vGlob, i), pEntry, k )
109 #define Vec_VecForEachEntryInt( vGlob, Entry, i, k ) \
110 for ( i = 0; i < Vec_VecSize(vGlob); i++ ) \
111 Vec_IntForEachEntry( Vec_VecEntryInt(vGlob, i), Entry, k )
112 #define Vec_VecForEachEntryIntLevel( vGlob, Entry, i, Level ) \
113 Vec_IntForEachEntry( Vec_VecEntryInt(vGlob, Level), Entry, i )
114 #define Vec_VecForEachEntryIntStart( vGlob, Entry, i, k, LevelStart ) \
115 for ( i = LevelStart; i < Vec_VecSize(vGlob); i++ ) \
116 Vec_IntForEachEntry( Vec_VecEntryInt(vGlob, i), Entry, k )
117 #define Vec_VecForEachEntryIntStartStop( vGlob, Entry, i, k, LevelStart, LevelStop ) \
118 for ( i = LevelStart; i < LevelStop; i++ ) \
119 Vec_IntForEachEntry( Vec_VecEntryInt(vGlob, i), Entry, k )
120 #define Vec_VecForEachEntryIntReverse( vGlob, Entry, i, k ) \
121 for ( i = 0; i < Vec_VecSize(vGlob); i++ ) \
122 Vec_IntForEachEntryReverse( Vec_VecEntryInt(vGlob, i), Entry, k )
123 #define Vec_VecForEachEntryIntReverseReverse( vGlob, Entry, i, k ) \
124 for ( i = Vec_VecSize(vGlob) - 1; i >= 0; i-- ) \
125 Vec_IntForEachEntryReverse( Vec_VecEntryInt(vGlob, i), Entry, k )
126 #define Vec_VecForEachEntryIntReverseStart( vGlob, Entry, i, k, LevelStart ) \
127 for ( i = LevelStart-1; i >= 0; i-- ) \
128 Vec_IntForEachEntry( Vec_VecEntryInt(vGlob, i), Entry, k )
149 if ( nCap > 0 && nCap < 8 )
153 p->pArray = p->nCap?
ABC_ALLOC(
void *, p->nCap ) : NULL;
173 for ( i = 0; i < nSize; i++ )
193 if ( p->nSize >= Level + 1 )
196 for ( i = p->nSize; i <= Level; i++ )
198 p->nSize = Level + 1;
203 if ( p->nSize >= Level + 1 )
206 for ( i = p->nSize; i <= Level; i++ )
208 p->nSize = Level + 1;
256 assert( i >= 0 && i < p->nSize );
273 assert( i >= 0 && i < p->nSize );
278 assert( i >= 0 && i < p->nSize );
297 if ( p == NULL )
return 0.0;
299 for ( i = 0; i < p->nSize; i++ )
308 if ( p == NULL )
return 0.0;
310 for ( i = 0; i < p->nSize; i++ )
422 Counter += vVec->nSize;
458 if ( p->nSize < Level + 1 )
462 for ( i = p->nSize; i < Level + 1; i++ )
464 p->nSize = Level + 1;
470 if ( p->nSize < Level + 1 )
474 for ( i = p->nSize; i < Level + 1; i++ )
476 p->nSize = Level + 1;
494 if ( p->nSize < Level + 1 )
501 if ( p->nSize < Level + 1 )
549 qsort( (
void *)p->pArray, p->nSize,
sizeof(
void *),
552 qsort( (
void *)p->pArray, p->nSize,
sizeof(
void *),
598 qsort( (
void *)p->pArray, p->nSize,
sizeof(
void *),
601 qsort( (
void *)p->pArray, p->nSize,
sizeof(
void *),
624 printf(
" %4d : {", i );
625 printf(
" %d", Entry );
static int Vec_VecSortCompare2(Vec_Ptr_t **pp1, Vec_Ptr_t **pp2)
#define Vec_VecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
static int Vec_VecSortCompare4(Vec_Int_t **pp1, Vec_Int_t **pp2)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
static void Vec_VecPush(Vec_Vec_t *p, int Level, void *Entry)
static Vec_Vec_t * Vec_VecAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static void Vec_VecSort(Vec_Vec_t *p, int fReverse)
static double Vec_IntMemory(Vec_Int_t *p)
static Vec_Int_t * Vec_IntDup(Vec_Int_t *pVec)
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
static double Vec_VecMemoryInt(Vec_Vec_t *p)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
static int Vec_PtrPushUnique(Vec_Ptr_t *p, void *Entry)
static void Vec_PtrGrow(Vec_Ptr_t *p, int nCapMin)
#define Vec_VecForEachLevelInt(vGlob, vVec, i)
static void * Vec_VecEntryEntry(Vec_Vec_t *p, int i, int k)
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 int Vec_PtrSize(Vec_Ptr_t *p)
static void Vec_VecFree(Vec_Vec_t *p)
#define Vec_VecForEachEntryInt(vGlob, Entry, i, k)
static void Vec_VecPushUniqueInt(Vec_Vec_t *p, int Level, int Entry)
static void Vec_VecClear(Vec_Vec_t *p)
static void Vec_IntGrow(Vec_Int_t *p, int nCapMin)
static Vec_Vec_t * Vec_VecDupInt(Vec_Vec_t *p)
static void Vec_VecPushInt(Vec_Vec_t *p, int Level, int Entry)
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static int Vec_IntEntry(Vec_Int_t *p, int i)
static int Vec_VecEntryEntryInt(Vec_Vec_t *p, int i, int k)
static void Vec_VecPrintInt(Vec_Vec_t *p, int fSkipSingles)
static void Vec_VecSortByFirstInt(Vec_Vec_t *p, int fReverse)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
static Vec_Vec_t * Vec_VecStart(int nSize)
static int Vec_VecLevelSize(Vec_Vec_t *p, int i)
static int Vec_VecCap(Vec_Vec_t *p)
static double Vec_PtrMemory(Vec_Ptr_t *p)
#define ABC_NAMESPACE_HEADER_END
static int Vec_VecSortCompare3(Vec_Int_t **pp1, Vec_Int_t **pp2)
static void Vec_VecExpandInt(Vec_Vec_t *p, int Level)
static Vec_Int_t * Vec_VecEntryInt(Vec_Vec_t *p, int i)
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static Vec_Vec_t * Vec_VecDup(Vec_Vec_t *p)
static void Vec_VecExpand(Vec_Vec_t *p, int Level)
static int Vec_VecSizeSize(Vec_Vec_t *p)
static int Vec_VecSize(Vec_Vec_t *p)
static void Vec_VecFreeP(Vec_Vec_t **p)
static void Vec_PtrClear(Vec_Ptr_t *p)
static Vec_Ptr_t * Vec_VecEntry(Vec_Vec_t *p, int i)
static int Vec_IntPushUnique(Vec_Int_t *p, int Entry)
static int Vec_VecSortCompare1(Vec_Ptr_t **pp1, Vec_Ptr_t **pp2)
static double Vec_VecMemory(Vec_Vec_t *p)
static void Vec_PtrFree(Vec_Ptr_t *p)
static void Vec_VecPushUnique(Vec_Vec_t *p, int Level, void *Entry)