231 while (node_off != 0)
242 parent_val = heap->
bh_nodes[parent_off];
253 heap->
bh_nodes[node_off] = parent_val;
254 node_off = parent_off;
257 heap->
bh_nodes[node_off] = node_val;
281 if (left_off < heap->bh_size &&
288 if (right_off < heap->bh_size &&
298 swap_off = right_off;
316 heap->
bh_nodes[node_off] = node_val;
void binaryheap_build(binaryheap *heap)
void binaryheap_add_unordered(binaryheap *heap, Datum d)
void binaryheap_reset(binaryheap *heap)
static void sift_down(binaryheap *heap, int node_off)
static int parent_offset(int i)
binaryheap * binaryheap_allocate(int capacity, binaryheap_comparator compare, void *arg)
Datum binaryheap_remove_first(binaryheap *heap)
static void sift_up(binaryheap *heap, int node_off)
static int right_offset(int i)
static int left_offset(int i)
void binaryheap_free(binaryheap *heap)
void binaryheap_replace_first(binaryheap *heap, Datum d)
Datum binaryheap_first(binaryheap *heap)
void binaryheap_add(binaryheap *heap, Datum d)
#define binaryheap_empty(h)
int(* binaryheap_comparator)(Datum a, Datum b, void *arg)
elog(ERROR, "%s: %s", p2, msg)
static int compare(const void *arg1, const void *arg2)
Assert(fmt[strlen(fmt) - 1] !='\n')
void pfree(void *pointer)
static int cmp(const chr *x, const chr *y, size_t len)
bool bh_has_heap_property
Datum bh_nodes[FLEXIBLE_ARRAY_MEMBER]
binaryheap_comparator bh_compare