Commit b2865919 authored by Guido van Rossum's avatar Guido van Rossum

Document that heappop() and heapreplace() raise IndexError if the heap

is empty.
parent 83dcf5a2
...@@ -45,7 +45,7 @@ heap invariant. ...@@ -45,7 +45,7 @@ heap invariant.
\begin{funcdesc}{heappop}{heap} \begin{funcdesc}{heappop}{heap}
Pop and return the smallest item from the \var{heap}, maintaining the 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} \end{funcdesc}
\begin{funcdesc}{heapify}{x} \begin{funcdesc}{heapify}{x}
...@@ -55,6 +55,7 @@ Transform list \var{x} into a heap, in-place, in linear time. ...@@ -55,6 +55,7 @@ Transform list \var{x} into a heap, in-place, in linear time.
\begin{funcdesc}{heapreplace}{heap, item} \begin{funcdesc}{heapreplace}{heap, item}
Pop and return the smallest item from the \var{heap}, and also push Pop and return the smallest item from the \var{heap}, and also push
the new \var{item}. The heap size doesn't change. 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 This is more efficient than \function{heappop()} followed
by \function{heappush()}, and can be more appropriate when using by \function{heappush()}, and can be more appropriate when using
a fixed-size heap. Note that the value returned may be larger a fixed-size heap. Note that the value returned may be larger
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment