]> granicus.if.org Git - python/commitdiff
Document new heapreplace() function.
authorTim Peters <tim.peters@gmail.com>
Sat, 3 Aug 2002 18:53:28 +0000 (18:53 +0000)
committerTim Peters <tim.peters@gmail.com>
Sat, 3 Aug 2002 18:53:28 +0000 (18:53 +0000)
Doc/lib/libheapq.tex

index d1aaaae6008cdc9ac90f92ee9006e11043ec17e7..38c38d816d1f477602f42d98d4bf403dada43bed 100644 (file)
@@ -52,6 +52,15 @@ heap invariant.
 Transform list \var{x} into a heap, in-place, in linear time.
 \end{funcdesc}
 
+\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.
+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
+than \var{item}!  That constrains reasonable uses of this routine.
+\end{funcdesc}
+
 Example of use:
 
 \begin{verbatim}