package batteries
A community-maintained standard library extension
Install
Dune Dependency
Authors
Maintainers
Sources
v3.5.1.tar.gz
md5=d3d16ffc960e832a1c0e21b7123194e9
sha512=36c8561079aa9fefc864c2f03bd8ae20aa05987bb67e7a9beac3ab4f440dbf7d44f141c172b05fddb1a5b618fc55a27962bb45fc39bd7b3a15d56e0ed3ff3870
doc/batteries.unthreaded/BatHeap/index.html
Module BatHeap
Functional heaps over ordered types
Ascribes to:
BatEnum.Enumerable with type 'a enumerable = 'a t
val size : 'a t -> int
Number of elements in the heap. O(1)
Construction
val empty : 'a t
The empty heap.
add x h
is the same as insert h x
. This function is intended to be used with fold_right
.
Operations
val find_min : 'a t -> 'a
Find the minimal element of the heap. O(1)
Transformation
val of_list : 'a list -> 'a t
Build a heap from a given list. O(n log n)
val to_list : 'a t -> 'a list
Enumerate the elements of the heap. O(n log n)
val elems : 'a t -> 'a list
Build a heap from an enumeration. Consumes the enumeration. O(n log n)
Enumerate the elements of the heap in heap order. O(log n) per BatEnum.get
.
Printing
val print :
?first:string ->
?last:string ->
?sep:string ->
('a, 'b) BatIO.printer ->
('a t, 'b) BatIO.printer
Print the contents of the heap in heap order. O(n log n)
Functorized version
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page