28#define FXU_HEAP_SINGLE_WEIGHT(pSingle) ((pSingle)->Weight)
29#define FXU_HEAP_SINGLE_CURRENT(p, pSingle) ((p)->pTree[(pSingle)->HNum])
30#define FXU_HEAP_SINGLE_PARENT_EXISTS(p, pSingle) ((pSingle)->HNum > 1)
31#define FXU_HEAP_SINGLE_CHILD1_EXISTS(p, pSingle) (((pSingle)->HNum << 1) <= p->nItems)
32#define FXU_HEAP_SINGLE_CHILD2_EXISTS(p, pSingle) ((((pSingle)->HNum << 1)+1) <= p->nItems)
33#define FXU_HEAP_SINGLE_PARENT(p, pSingle) ((p)->pTree[(pSingle)->HNum >> 1])
34#define FXU_HEAP_SINGLE_CHILD1(p, pSingle) ((p)->pTree[(pSingle)->HNum << 1])
35#define FXU_HEAP_SINGLE_CHILD2(p, pSingle) ((p)->pTree[((pSingle)->HNum << 1)+1])
36#define FXU_HEAP_SINGLE_ASSERT(p, pSingle) assert( (pSingle)->HNum >= 1 && (pSingle)->HNum <= p->nItemsAlloc )
64 p->nItemsAlloc = 2000;
127 fprintf( pFile,
"The contents of the heap:\n" );
128 fprintf( pFile,
"Level %d: ", Degree );
131 assert( Counter ==
p->pTree[Counter]->HNum );
133 if ( ++Counter == (1 << Degree) )
135 fprintf( pFile,
"\n" );
137 fprintf( pFile,
"Level %d: ", Degree );
140 fprintf( pFile,
"\n" );
141 fprintf( pFile,
"End of the heap printout.\n" );
178 int Weight1, Weight2;
183 assert( Weight1 >= Weight2 );
189 assert( Weight1 >= Weight2 );
206 if (
p->nItems ==
p->nItemsAlloc )
207 Fxu_HeapSingleResize(
p );
209 p->pTree[++
p->nItems] = pSingle;
210 pSingle->
HNum =
p->nItems;
212 Fxu_HeapSingleMoveUp(
p, pSingle );
231 Fxu_HeapSingleMoveUp(
p, pSingle );
234 Fxu_HeapSingleMoveDn(
p, pSingle );
237 Fxu_HeapSingleMoveDn(
p, pSingle );
253 int Place = pSingle->
HNum;
257 p->pTree[Place] =
p->pTree[
p->nItems--];
258 p->pTree[Place]->HNum = Place;
277 if (
p->nItems == 0 )
296 if (
p->nItems == 0 )
299 pSingle =
p->pTree[1];
303 p->pTree[1] =
p->pTree[
p->nItems--];
304 p->pTree[1]->HNum = 1;
306 Fxu_HeapSingleMoveDn(
p,
p->pTree[1] );
323 if (
p->nItems == 0 )
346 *pSingle1 = *pSingle2;
348 Temp = (*pSingle1)->
HNum;
349 (*pSingle1)->HNum = (*pSingle2)->HNum;
350 (*pSingle2)->HNum = Temp;
373 Fxu_HeapSingleSwap( ppSingle, ppPar );
394 Fxu_Single ** ppChild1, ** ppChild2, ** ppSingle;
415 Fxu_HeapSingleSwap( ppSingle, ppChild1 );
421 Fxu_HeapSingleSwap( ppSingle, ppChild2 );
436 Fxu_HeapSingleSwap( ppSingle, ppChild1 );
#define ABC_ALLOC(type, num)
#define ABC_REALLOC(type, obj, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
Fxu_HeapSingle * Fxu_HeapSingleStart()
FUNCTION DEFINITIONS ///.
#define FXU_HEAP_SINGLE_CHILD2_EXISTS(p, pSingle)
#define FXU_HEAP_SINGLE_CURRENT(p, pSingle)
Fxu_Single * Fxu_HeapSingleReadMax(Fxu_HeapSingle *p)
void Fxu_HeapSingleUpdate(Fxu_HeapSingle *p, Fxu_Single *pSingle)
#define FXU_HEAP_SINGLE_WEIGHT(pSingle)
DECLARATIONS ///.
#define FXU_HEAP_SINGLE_ASSERT(p, pSingle)
Fxu_Single * Fxu_HeapSingleGetMax(Fxu_HeapSingle *p)
#define FXU_HEAP_SINGLE_CHILD1(p, pSingle)
void Fxu_HeapSingleInsert(Fxu_HeapSingle *p, Fxu_Single *pSingle)
void Fxu_HeapSingleStop(Fxu_HeapSingle *p)
void Fxu_HeapSingleDelete(Fxu_HeapSingle *p, Fxu_Single *pSingle)
void Fxu_HeapSingleCheckOne(Fxu_HeapSingle *p, Fxu_Single *pSingle)
#define FXU_HEAP_SINGLE_PARENT(p, pSingle)
#define FXU_HEAP_SINGLE_CHILD2(p, pSingle)
#define FXU_HEAP_SINGLE_CHILD1_EXISTS(p, pSingle)
void Fxu_HeapSingleCheck(Fxu_HeapSingle *p)
int Fxu_HeapSingleReadMaxWeight(Fxu_HeapSingle *p)
void Fxu_HeapSinglePrint(FILE *pFile, Fxu_HeapSingle *p)
#define FXU_HEAP_SINGLE_PARENT_EXISTS(p, pSingle)
struct FxuSingle Fxu_Single
#define Fxu_HeapSingleForEachItem(Heap, Single)
struct FxuHeapSingle Fxu_HeapSingle