node* heap_delete() { node* ret = pq[1]->v ; swap(1,n) ; pq[n--] = NULL ; sinkDown(1) ; return ret ; }
void* heap_remove(heap_t* h) { if (h->size == 0) return NULL; void* ret = h->tree[0].data; if (--h->size != 0) { xchg(h, 0, h->size); sinkDown(h, 0); } if (h->size < h->avail/4) { h->avail /= 2; h->tree = (hnode_t*) realloc(h->tree, sizeof(hnode_t)*h->avail); assert(h->tree != NULL); } return ret; }