circuitpython/docs/library/uheapq.rst

34 lines
879 B
ReStructuredText
Raw Normal View History

2014-10-31 18:21:37 -04:00
:mod:`uheapq` -- heap queue algorithm
=====================================
.. include:: ../templates/unsupported_in_circuitpython.inc
.. module:: uheapq
:synopsis: heap queue algorithm
|see_cpython_module| :mod:`cpython:heapq`.
This module implements the
`min heap queue algorithm <https://en.wikipedia.org/wiki/Heap_%28data_structure%29>`_.
A heap queue is essentially a list that has its elements stored in such a way
that the first item of the list is always the smallest.
Functions
---------
.. function:: heappush(heap, item)
Push the ``item`` onto the ``heap``.
.. function:: heappop(heap)
Pop the first item from the ``heap``, and return it. Raise ``IndexError`` if
``heap`` is empty.
2021-06-18 11:54:19 -04:00
The returned item will be the smallest item in the ``heap``.
.. function:: heapify(x)
Convert the list ``x`` into a heap. This is an in-place operation.