void isc_heap_decreased(isc_heap_t *heap, unsigned int index) { REQUIRE(VALID_HEAP(heap)); REQUIRE(index >= 1 && index <= heap->last); sink_down(heap, index, heap->array[index]); }
int heap_decreased(heap_context ctx, int i) { if (ctx == NULL || i < 1 || i > ctx->heap_size) { errno = EINVAL; return (-1); } sink_down(ctx, i, ctx->heap[i]); return (0); }
void isc_heap_delete(isc_heap_t *heap, unsigned int index) { void *elt; isc_boolean_t less; REQUIRE(index >= 1 && index <= heap->last); if (index == heap->last) { heap->last--; } else { elt = heap->array[heap->last--]; less = heap->compare(elt, heap->array[index]); heap->array[index] = elt; if (less) float_up(heap, index, heap->array[index]); else sink_down(heap, index, heap->array[index]); } }
int heap_delete(heap_context ctx, int i) { void *elt; int less; if (ctx == NULL || i < 1 || i > ctx->heap_size) { errno = EINVAL; return (-1); } if (i == ctx->heap_size) { ctx->heap_size--; } else { elt = ctx->heap[ctx->heap_size--]; less = ctx->higher_priority(elt, ctx->heap[i]); ctx->heap[i] = elt; if (less) float_up(ctx, i, ctx->heap[i]); else sink_down(ctx, i, ctx->heap[i]); } return (0); }
void isc_heap_delete(isc_heap_t *heap, unsigned int idx) { void *elt; isc_boolean_t less; REQUIRE(VALID_HEAP(heap)); REQUIRE(idx >= 1 && idx <= heap->last); if (idx == heap->last) { heap->array[heap->last] = NULL; heap->last--; } else { elt = heap->array[heap->last]; heap->array[heap->last] = NULL; heap->last--; less = heap->compare(elt, heap->array[idx]); heap->array[idx] = elt; if (less) float_up(heap, idx, heap->array[idx]); else sink_down(heap, idx, heap->array[idx]); } }