mirror of https://github.com/python/cpython
Document new heapreplace() function.
This commit is contained in:
parent
6e0da82a97
commit
0ad679ff0f
|
@ -52,6 +52,15 @@ heap invariant.
|
||||||
Transform list \var{x} into a heap, in-place, in linear time.
|
Transform list \var{x} into a heap, in-place, in linear time.
|
||||||
\end{funcdesc}
|
\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:
|
Example of use:
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
|
|
Loading…
Reference in New Issue