49#ifdef FOR_TRITE_TEST_PROGRAM
50#define LEQ(x,y) (*pq->leq)(x,y)
54#define LEQ(x,y) VertLeq((GLUvertex *)x, (GLUvertex *)y)
61 if (pq == NULL)
return NULL;
66 if (pq->
nodes == NULL) {
103 hCurr =
n[curr].handle;
106 if( child < pq->size &&
LEQ(
h[
n[child+1].handle].key,
107 h[
n[child].handle].key )) {
111 assert(child <= pq->max);
113 hChild =
n[child].handle;
114 if( child > pq->
size ||
LEQ(
h[hCurr].key,
h[hChild].key )) {
115 n[curr].handle = hCurr;
116 h[hCurr].node = curr;
119 n[curr].handle = hChild;
120 h[hChild].node = curr;
133 hCurr =
n[curr].handle;
136 hParent =
n[parent].handle;
137 if( parent == 0 ||
LEQ(
h[hParent].key,
h[hCurr].key )) {
138 n[curr].handle = hCurr;
139 h[hCurr].node = curr;
142 n[curr].handle = hParent;
143 h[hParent].node = curr;
155 for( i = pq->
size; i >= 1; --i ) {
169 if( (curr*2) > pq->
max ) {
177 ((pq->
max + 1) *
sizeof( pq->
nodes[0] )));
178 if (pq->
nodes == NULL) {
179 pq->
nodes = saveNodes;
206 assert(free_handle != LONG_MAX);
219 n[1].handle =
n[pq->
size].handle;
220 h[
n[1].handle].node = 1;
226 if( -- pq->
size > 0 ) {
240 assert( hCurr >= 1 && hCurr <= pq->max &&
h[hCurr].key != NULL );
242 curr =
h[hCurr].node;
243 n[curr].handle =
n[pq->
size].handle;
244 h[
n[curr].handle].node = curr;
246 if( curr <= -- pq->size ) {
247 if( curr <= 1 ||
LEQ(
h[
n[curr>>1].handle].key,
h[
n[curr].handle].key )) {
void pqInit(PriorityQ *pq)
static void FloatDown(PriorityQ *pq, long curr)
void pqDeletePriorityQ(PriorityQ *pq)
PriorityQ * pqNewPriorityQ(int(*leq)(PQkey key1, PQkey key2))
static void FloatUp(PriorityQ *pq, long curr)
void pqDelete(PriorityQ *pq, PQhandle hCurr)
PQkey pqExtractMin(PriorityQ *pq)
PQhandle pqInsert(PriorityQ *pq, PQkey keyNew)
int(* leq)(PQkey key1, PQkey key2)