MCPcopy Create free account
hub / github.com/ActiveState/code / replace

Method replace

recipes/Python/440673_Safe_heap_queue_class/recipe-440673.py:30–34  ·  view source on GitHub ↗

Equivalent to "x = heap.popmin(); heap.push(); return x" but more efficient.

(self, item)

Source from the content-addressed store, hash-verified

28 return self._unwrap(heapq.heappop(self._lst))
29
30 def replace(self, item):
31 '''Equivalent to "x = heap.popmin(); heap.push(); return x" but more
32 efficient.
33 '''
34 return self._unwrap(heapq.heapreplace(self._lst, self._wrap(item)))
35
36 def pushpop(self, item):
37 'Equivalent to "heap.push(); return heap.popmin()" but more efficient.'

Callers 15

pushpopMethod · 0.95
xssescapeFunction · 0.45
exportFunction · 0.45
covert_uncFunction · 0.45
mainFunction · 0.45
finalFunction · 0.45
yieldattrMethod · 0.45
parseMethod · 0.45
__init__Method · 0.45
__str__Method · 0.45
m_unicodeMethod · 0.45
compileMethod · 0.45

Calls 2

_unwrapMethod · 0.95
_wrapMethod · 0.95

Tested by

no test coverage detected