A binary heap is a tree with keys and associated values that satisfies the heap codition: the key of every node is greater than or equal to the key of its parent, if it has one. The main application of binary heaps are priority queues. To load the package, enter the query
| ?- use_module(library(heaps)).
add_to_heap(+OldHeap, +Key, +Datum, ?NewHeap)
| ?- add_to_heap(t(0,[],t),3,678,N). N = t(1,[],t(3,678,t,t)) ? yes
get_from_heap(+OldHeap, ?Key, ?Datum, ?NewHeap)
get_from_heap(t(1,[],t(1,543,t,t)),K,D,N). D = 543, K = 1, N = t(0,[1],t) ? yes
empty_heap(?Heap)
heap_size(+Heap, ?Size)
heap_to_list(+Heap, -List)
is_heap(+Heap)
list_to_heap(+List, -Heap)
| ?- list_to_heap([1-34,2-345,5-678],H). H = t(3,[],t(1,34,t(2,345,t,t),t(5,678,t,t))) ? yes
min_of_heap(+Heap, ?Key, ?Datum)
min_of_heap(+Heap, ?Key1, ?Datum1, ?Key2, ?Datum2)
delete_from_heap(+OldHeap, +Key, ?Datum, ?NewHeap)