module Heap:
The classic imperative array based heap data structure.
Adding elements and removing the minimum element
have logarithmic complexity.
The heap can take up to Sys.max_array_length
elements.
type
data = Ord.t
type
t
the heap
val create : data -> t
creates an empty heap. null element must be provided.
val add : t -> data -> unit
adds an element.
Raises OVERFLOW
if the heap is full.
val min : t -> data
returns the minimum element.
Raises Not_found
if the heap is empty.
val remove_min : t -> data
removes the minimum element and returns it.
Raises Not_found
if the heap is empty.
val iter : (data -> unit) -> t -> unit
iterates over all elements (in unsorted order).
val is_empty : t -> bool
no elements?
val size : t -> int
number of elements.