protocol
Heap protocol.
Richard O'Keefe; adapted to Logtalk by Paulo Moura and Victor Lagerkvist.
1.01
2010/11/13
static
(no dependencies on other files)
Inserts the new Key-Value pair into a heap, returning the updated heap.
static
insert(Key,Value,Heap,NewHeap)
insert(+key,+value,+heap,-heap) – one
Inserts a list of Key-Value pairs into a heap, returning the updated heap.
static
insert_all(List,Heap,NewHeap)
insert_all(@list(pairs),+heap,-heap) – one
Deletes and returns the top Key-Value pair in OldHeap and the resulting NewHeap.
static
delete(Heap,Key,Value,NewHeap)
delete(+heap,?key,?value,-heap) – zero_or_one
Merges two heaps.
static
merge(Heap1,Heap2,NewHeap)
merge(+heap,+heap,-heap) – one
True if the heap is empty.
static
empty(Heap)
empty(@heap) – zero_or_one
Returns the number of heap elements.
static
size(Heap,Size)
size(+heap,?integer) – zero_or_one
Returns the current set of Key-Value pairs in the Heap as a List, sorted into ascending order of Keys.
static
as_list(Heap,List)
as_list(+heap,-list) – one
Constructs a Heap from a list of Key-Value pairs.
static
as_heap(List,Heap)
as_heap(+list,-heap) – one
Returns the top Key-Value pair in Heap. Fails if the heap is empty.
static
top(Heap,Key,Value)
top(+heap,?key,?value) – zero_or_one
Returns the top pair, Key1-Value1, and the next pair, Key2-Value2, in Heap. Fails if the heap does not have at least two elements.
static
top_next(Heap,Key1,Value1,Key2,Value2)
top_next(+heap,?key,?value,?key,?value) – zero_or_one
(none)
(none)