From: Tim Peters Date: Sat, 3 Aug 2002 18:53:28 +0000 (+0000) Subject: Document new heapreplace() function. X-Git-Tag: v2.3c1~4744 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0ad679ff0f014c3c29fb839f33c027d7d928a09a;p=python Document new heapreplace() function. --- diff --git a/Doc/lib/libheapq.tex b/Doc/lib/libheapq.tex index d1aaaae600..38c38d816d 100644 --- a/Doc/lib/libheapq.tex +++ b/Doc/lib/libheapq.tex @@ -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}