Go to the previous, next section.
A binary heap is a tree with keys and associated values that satisfies the heap property: the key of every node other than the root is greater than the key of its parent node. The main application of binary heaps are priority queues. To load the package, enter the query
| ?- use_module(library(heaps)).
| ?- add_to_heap(t(0,[],t),3,678,N). N = t(1,[],t(3,678,t,t)) ? yes
get_from_heap(t(1,[],t(1,543,t,t)),K,D,N). D = 543, K = 1, N = t(0,[1],t) ? yes
| ?- 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
Go to the previous, next section.