diff options
author | Guido van Rossum <guido@python.org> | 2002-08-07 18:56:08 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2002-08-07 18:56:08 (GMT) |
commit | b2865919cc150d3cf682d06ccc99d8de285b1de3 (patch) | |
tree | b951568aa97465e374b67f41ee5d1120d324cb6b /Doc/lib/libheapq.tex | |
parent | 83dcf5a290a5449dacc519a21c611af74291cde6 (diff) | |
download | cpython-b2865919cc150d3cf682d06ccc99d8de285b1de3.zip cpython-b2865919cc150d3cf682d06ccc99d8de285b1de3.tar.gz cpython-b2865919cc150d3cf682d06ccc99d8de285b1de3.tar.bz2 |
Document that heappop() and heapreplace() raise IndexError if the heap
is empty.
Diffstat (limited to 'Doc/lib/libheapq.tex')
-rw-r--r-- | Doc/lib/libheapq.tex | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Doc/lib/libheapq.tex b/Doc/lib/libheapq.tex index 38c38d8..38f9b1a 100644 --- a/Doc/lib/libheapq.tex +++ b/Doc/lib/libheapq.tex @@ -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 |