InPlace.Heap (inplace v0.7.1)

Copy Markdown

Binary heap. NOTE:

  • The heap keys are limited to integers.
  • The capacity of the heap has to be specified at the time of creation.

Summary

Functions

decrease_key(heap, key, delta)

default_opts()

empty?(heap)

extract_min(heap)

get_key(heap, position, heap_size \\ nil)

get_key_position(heap, index)

get_max(heap)

get_min(heap)

heapify(heap)

heapify(heap, position)

insert(heap, key)

new(capacity, opts \\ [])

Initialize. All values are initially null. The element at capacity+1 is used to track the heap size. Options:

  • comparator - function of arity 2, returns true if 1st argument strictly 'lesser' than 2nd. lesser is understood as the ordering function. Arguments could be of any type. Default: &Kernel.</2
  • getter - function of arity 1; takes an integer (key) as argument and returns value of type integer() Default:

sift_down(heap, position)

sift_up(heap, position, key \\ nil)

size(heap)

valid?(heap)