Skip to content
Closed
Prev Previous commit
Next Next commit
docs
  • Loading branch information
kristjanvalur committed Jan 5, 2024
commit acd9e06dea298b7b79fe6de715821459fe9a089e
19 changes: 11 additions & 8 deletions Doc/library/heapq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ The following functions are provided:
invariant. If the heap is empty, :exc:`IndexError` is raised. To access the
smallest item without popping it, use ``heap[0]``.

This is equivalent to performing ``heapremove(heap, 0)``.


.. function:: heappushpop(heap, item)

Expand Down Expand Up @@ -80,17 +82,18 @@ The following functions are provided:
on the heap.


.. function:: heapremove(heap, index, item=None):
.. function:: heapremove(heap, index):

Remove the item at ``heap[index]`` while maintaining the heap invariant.

Returns the removed item.

.. versionadded:: 3.13

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change these to next


Remove the item at ``heap[index]``, optionally replacing it with *item*,
while maintaining the heap invariant.

This is more efficient than performing ``del heap[index]`` followed
by :func:`heapify`.
.. function:: heapfix(heap, index):

In case an items *value* has changed and its index is known, this
function can be used to restore the heap invariant:
``heapremove(heap, item_index, item)``
Restore the heap invariant after the object at ``heap[index]`` has been modified.

.. versionadded:: 3.13

Expand Down