40 PQgen(PQ* pq,
int sz,
PQTYPE guard)
49 PQfree(PQ* pq,
int freeAll)
52 if (freeAll) free (pq);
67 for (i = 1; i <= pq->PQcnt; i++) {
68 if (
N_IDX(pq,pq->pq[i]) != i) {
77 PQupheap(PQ* ppq,
int k)
85 while (
N_VAL(ppq,n = pq[next]) < v) {
98 if (pq->PQcnt == pq->PQsize) {
103 pq->pq[pq->PQcnt] = np;
104 PQupheap (pq, pq->PQcnt);
112 PQdownheap (PQ* ppq,
int k)
117 int lim = ppq->PQcnt/2;
124 if (j < ppq->PQcnt) {
130 if (v >=
N_VAL(ppq,n))
break;
146 pq->pq[1] = pq->pq[pq->PQcnt];
148 if (pq->PQcnt) PQdownheap (pq, 1);
154 else return pq->pq[0];
161 PQupheap (pq,
N_IDX(pq,n));
175 fprintf (stderr,
"Q: ");
176 for (i = 1; i <= pq->PQcnt; i++) {
178 fprintf (stderr,
"(%d:%f) ",
N_IDX(pq,n),
N_VAL(pq,n));
180 fprintf (stderr,
"\n");
int agerr(agerrlevel_t level, const char *fmt,...)
void PQinsert(Halfedge *he, Site *v, double offset)