21 #ifndef ABC__misc__vec__Queue_h
22 #define ABC__misc__vec__Queue_h
97 assert( p->pCostsFlt == NULL );
98 p->pCostsFlt = pCosts;
102 if ( p->nCap >= nCapMin )
105 p->pOrder =
ABC_REALLOC(
int, p->pOrder, nCapMin );
106 memset( p->pHeap + p->nCap, 0xff, (nCapMin - p->nCap) *
sizeof(
int) );
107 memset( p->pOrder + p->nCap, 0xff, (nCapMin - p->nCap) *
sizeof(
int) );
113 assert( p->pHeap[0] == -1 );
114 for ( i = 1; i < p->nSize; i++ )
116 assert( p->pHeap[i] >= 0 && p->pOrder[p->pHeap[i]] == i );
117 p->pOrder[p->pHeap[i]] = -1;
162 int i = p->pOrder[v];
165 assert( p->pOrder[v] != -1 );
166 assert( p->pHeap[i] == v );
167 while ( i > 1 && Cost >
Vec_QuePrio(p, p->pHeap[parent]) )
169 p->pHeap[i] = p->pHeap[parent];
170 p->pOrder[p->pHeap[i]] = i;
182 int i = p->pOrder[v];
184 while ( child < p->nSize )
188 assert( child < p->nSize );
191 p->pHeap[i] = p->pHeap[child];
192 p->pOrder[p->pHeap[i]] = i;
219 return (
int)( v < p->nCap && p->pOrder[v] >= 0 );
223 if ( p->nSize >= p->nCap )
227 assert( p->nSize < p->nCap );
228 assert( p->pOrder[v] == -1 );
229 assert( p->pHeap[p->nSize] == -1 );
230 p->pOrder[v] = p->nSize;
231 p->pHeap[p->nSize++] = v;
238 Res = p->pHeap[1]; p->pOrder[Res] = -1;
239 if ( --p->nSize == 1 )
244 v = p->pHeap[p->nSize]; p->pHeap[p->nSize] = -1;
245 p->pHeap[1] = v; p->pOrder[v] = 1;
264 for ( i = k = 1; i < p->nSize; i += k, k *= 2 )
266 for ( m = 0; m < k; m++ )
267 if ( i+m < p->nSize )
268 printf(
"%-5d", p->pHeap[i+m] );
270 for ( m = 0; m < k; m++ )
271 if ( i+m < p->nSize )
293 assert( p->nSize <= p->nCap );
295 for ( i = 0; i < p->nSize-1; i++ )
296 assert( p->pOrder[i] > 0 );
297 for ( ; i < p->nCap; i++ )
298 assert( p->pOrder[i] == -1 );
300 assert( p->pHeap[0] == -1 );
301 for ( i = 0; i < p->nSize-1; i++ )
302 assert( p->pHeap[p->pOrder[i]] == i );
303 for ( i++; i < p->nCap; i++ )
304 assert( p->pHeap[i] == -1 );
306 for ( i = 1; i < p->nSize; i++ )
309 if ( child < p->nSize )
312 if ( child < p->nSize )
static void Vec_QueGrow(Vec_Que_t *p, int nCapMin)
static void Vec_QuePrint(Vec_Que_t *p)
static int Vec_QueMoveUp(Vec_Que_t *p, int v)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
static void Vec_QueCheck(Vec_Que_t *p)
#define ABC_REALLOC(type, obj, num)
static float Vec_QueTopPriority(Vec_Que_t *p)
static void Vec_QueMoveDown(Vec_Que_t *p, int v)
typedefABC_NAMESPACE_HEADER_START struct Vec_Que_t_ Vec_Que_t
INCLUDES ///.
static int Vec_QueTop(Vec_Que_t *p)
static int Vec_QuePop(Vec_Que_t *p)
static int Abc_MaxInt(int a, int b)
static void Vec_QueClear(Vec_Que_t *p)
static int Vec_QueSize(Vec_Que_t *p)
static void Vec_QueFreeP(Vec_Que_t **p)
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static void Vec_IntPush(Vec_Int_t *p, int Entry)
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
#define ABC_NAMESPACE_HEADER_END
static float Vec_QuePrio(Vec_Que_t *p, int v)
static int Vec_IntSize(Vec_Int_t *p)
static float ** Vec_FltArrayP(Vec_Flt_t *p)
static void Vec_QueUpdate(Vec_Que_t *p, int v)
#define ABC_CALLOC(type, num)
typedefABC_NAMESPACE_HEADER_START struct Vec_Flt_t_ Vec_Flt_t
INCLUDES ///.
static int Vec_QueIsMember(Vec_Que_t *p, int v)
static void Vec_QueFree(Vec_Que_t *p)
static void Vec_QueTest(Vec_Flt_t *vCosts)
#define ABC_INFINITY
MACRO DEFINITIONS ///.
static void Vec_IntFree(Vec_Int_t *p)
static int Vec_FltSize(Vec_Flt_t *p)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
static Vec_Que_t * Vec_QueAlloc(int nCap)
MACRO DEFINITIONS ///.
static void Vec_QuePush(Vec_Que_t *p, int v)
static void Vec_QueSetPriority(Vec_Que_t *p, float **pCosts)
#define ABC_FALLOC(type, num)