mirror of
https://github.com/python/cpython.git
synced 2026-03-06 04:50:58 +00:00
Document that heappop() and heapreplace() raise IndexError if the heap
is empty.
This commit is contained in:
parent
83dcf5a290
commit
b2865919cc
1 changed files with 2 additions and 1 deletions
|
|
@ -45,7 +45,7 @@ heap invariant.
|
|||
|
||||
\begin{funcdesc}{heappop}{heap}
|
||||
Pop and return the smallest item from the \var{heap}, maintaining the
|
||||
heap invariant.
|
||||
heap invariant. If the heap is empty, \exception{IndexError} is raised.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{heapify}{x}
|
||||
|
|
@ -55,6 +55,7 @@ Transform list \var{x} into a heap, in-place, in linear time.
|
|||
\begin{funcdesc}{heapreplace}{heap, item}
|
||||
Pop and return the smallest item from the \var{heap}, and also push
|
||||
the new \var{item}. The heap size doesn't change.
|
||||
If the heap is empty, \exception{IndexError} is raised.
|
||||
This is more efficient than \function{heappop()} followed
|
||||
by \function{heappush()}, and can be more appropriate when using
|
||||
a fixed-size heap. Note that the value returned may be larger
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue