package core_kernel
- Overview
- No Docs
You can search for identifiers within the package.
in-package search v0.2.0
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=34a0288f16027c6b90e4ad16cb5cc677d7063d310faf918748ce70f1745116c0
doc/core_kernel.fheap/Fheap/index.html
Module FheapSource
Functional heaps (implemented as pairing heaps).
t_of_sexp is not supported, because of the difficulty involved in recreating the comparison function.
Even though min_elt, max_elt, and to_list are in Container.S1, they are documented separately to make sure there is no confusion.
include Core.Container.S1 with type 'a t := 'a t
Fheap may be used as the module argument to Sequence.merge_all.
include Core.Sequence.Heap with type 'a t := 'a t
The comparison functions in min_elt and max_elt are independent of the one used to order the heap. Since the provided compare may be different from the one used to create the heap, it is necessary for these functions to traverse the entire heap. If you want to access the smallest element of the heap according to the heap's comparison function, you should use top.
The elements of to_list t are not in any particular order. You need to sort the list afterwards if you want to get a sorted list.
create ~compare returns a new min-heap that uses ordering function compare.
The top of the heap is the smallest element as determined by the provided comparison function.
This returns the top (i.e., smallest) element of the heap. Complexity O(1).
remove_top t returns the new heap after a remove. It does nothing if t is empty.
The amortized time per remove_top t (or pop t, pop_exn t, pop_if t) is O(lg n). The complexity of the worst case is O(n).
This removes and returns the top (i.e., least) element and the modified heap.
pop_if t cond returns Some (top_element, rest_of_heap) if t is not empty and its top element satisfies condition cond, or None in any other case.