A list that maintains the heap invariant.
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440673
TODO using things like pop() is unsafe! they rely on the unimplemented
_get_element()
|
|
__init__(self,
iterable=(),
key=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature |
source code
|
|
|
|
|
|
|
push(self,
item)
Push the item onto the heap. |
source code
|
|
|
|
popmin(self)
Pop the smallest item off the heap |
source code
|
|
|
|
replace(self,
item)
Equivalent to "x = heap.popmin(); heap.push(); return x"
but more efficient. |
source code
|
|
|
|
pushpop(self,
item)
Equivalent to "heap.push(); return heap.popmin()" but more
efficient. |
source code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Inherited from ListMixin:
__add__,
__copy__,
__deepcopy__,
__getitem__,
__hash__,
__iadd__,
__imul__,
__mul__,
__radd__,
__repr__,
__rmul__,
__str__,
index,
pop,
remove
Inherited from object:
__delattr__,
__format__,
__getattribute__,
__new__,
__reduce__,
__reduce_ex__,
__setattr__,
__sizeof__,
__subclasshook__
|