package owl-base
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=08c63c2c6f4a73143062ae1d2b7a809cdc8ae829a50b5bb1ecd9de6e2e5a5549
sha512=574cc39a186ef89bf73fbd9e42dd555b0d03ac1f70f745bc3f0932c623d217030a6375b6418fe4f262d9bff161ff254df10ba27d8f5fa8783c86e88af0755305
doc/owl-base/Owl_utils_heap/index.html
Module Owl_utils_heap
Source
Type definition
Type of a min heap.
Basic functions
``make cmp`` creates an empty min heap, using ``cmp`` as a comparison function.
``make_int ?initial_size cmp`` creates an empty integer heap, using ``cmp`` as a comparison function and pre-allocates a space of ``initial_size`` elements.
``make_float ?initial_size cmp`` creates an empty float heap, using ``cmp`` as a comparison function and pre-allocates a space of ``initial_size`` elements.
``push heap x`` pushes ``x`` into ``heap``. Time complexity is ``O(log(n))``, where n is the size of ``heap``.
``pop heap`` pops the minimal element from ``heap``. It raises an exception if the heap is empty. Time complexity is ``O(log(n))``, where n is the size of ``heap``.
``peek heap`` returns the value of the minimal element in ``heap`` but it does not remove the element from the heap. Raises an exception if the heap is empty. Time complexity is ``O(1)``.
``is_empty heap`` returns ``true`` if ``heap`` is empty, ``false`` otherwise.