module Heap:Min-heap implementation, adapted from CLR.sig..end
exception Empty
top or pop is called on an empty heap.type 'a t
type 'a heap_el
val heap_el_is_valid : 'a heap_el -> boolheap_el_is_valid heap_eltrue iff heap element is member
of a heap.val heap_el_get_el : 'a heap_el -> 'aheap_el_get_el heap_elval length : 'a t -> intlength heapheap.val is_empty : 'a t -> boolis_empty heaptrue iff heap does not contain any
elements.val get_cmp : 'a t -> 'a -> 'a -> intget_cmp heapheap.val create : ?min_size:int -> ('a -> 'a -> int) -> 'a tcreate ?min_size cmpmin_size
elements without reallocations, using ordering function cmp.
If cmp x y < 0 (i.e. x < y), then x will be on "top" of y in the heap.
That is, Heap.pop will remove x before y.
val of_array : ?min_size:int -> ('a -> 'a -> int) -> 'a array -> 'a tof_array ?min_size cmp armin_size elements without reallocations, using ordering function
cmp, and initialize it with the elements of ar.val copy : 'a t -> 'a tcopy heapheap.val mem : 'a t -> 'a -> boolmem heap eltrue iff el is member of heap.
Requires linear time in worst case.val heap_el_mem : 'a t -> 'a heap_el -> boolheap_el_mem heap heap_eltrue iff heap_el is member of
heap. Requires constant time only.val find_heap_el : 'a t -> 'a -> 'a heap_elfind_heap_el heap elNot_found if el could not be found.el in heap.val top : 'a t -> 'a optiontop heapSome top_element of heap without
changing it, or None if heap is empty.val top_exn : 'a t -> 'atop_exn heapEmpty if heap is empty.heap without changing it.val top_heap_el : 'a t -> 'a heap_el optiontop_heap_el heapSome top_heap_el of heap without
changing it, or None if heap is empty.val top_heap_el_exn : 'a t -> 'a heap_eltop_heap_el_exn heapEmpty if heap is empty.heap
without changing it.val iter : 'a t -> f:('a -> unit) -> unititer heap ~f iterate over heap with function f. The elements
are passed in an unspecified order.val pop : 'a t -> 'a optionpop heapSome top_element of heap, removing it,
or None if heap is empty.val pop_exn : 'a t -> 'apop_exn heapEmpty if heap is empty.heap, removing it.val pop_heap_el : 'a t -> 'a heap_el optionpop_heap_el heapSome top_heap_element, removing
it, or None if heap is empty.val pop_heap_el_exn : 'a t -> 'a heap_elpop_heap_el_exn heapEmpty if heap is empty.heap,
removing it.val cond_pop : 'a t -> ('a -> bool) -> 'a optioncond_pop heap condSome top_element of heap if it
fills condition cond, removing it, or None in any other case.val cond_pop_heap_el : 'a t -> ('a -> bool) -> 'a heap_el optioncond_pop_heap_el heap condSome top_heap_element of
heap if the associated element fills condition cond, removing it,
or None in any other case.val push : 'a t -> 'a -> 'a heap_elpush heap el pushes element el on heap.val push_heap_el : 'a t -> 'a heap_el -> unitpush_heap_el heap heap_el pushes heap_el on heap.Failure if heap_el is already member of some heap.val remove : 'a heap_el -> unitremove heap_el removes heap_el from its associated heap.Failure if heap_el is not member of any heap.val update : 'a heap_el -> 'a -> unitupdate heap_el el updates heap_el with element el in its
associated heap.Failure if heap_el is not member of any heap.check_heap_property h asserts that h has the heap property: that all
nodes are less than their children by h's comparison function.val check_heap_property : 'a t -> bool