Lines Matching refs:item
11 heappush(heap, item) # pushes a new item on the heap
12 item = heappop(heap) # pops the smallest item from the heap
13 item = heap[0] # smallest item on the heap without popping it
15 item = heappushpop(heap, item) # pushes a new item and then returns
16 # the smallest item; the heap size is unchanged
17 item = heapreplace(heap, item) # pops and returns smallest item, and adds
18 # new item; the heap size is unchanged
26 - Our heappop() method returns the smallest item, not the largest.
29 without surprises: heap[0] is the smallest item, and heap.sort()
103 Moreover, if you output the 0'th item on disk and get an input which
132 def heappush(heap, item):
133 """Push item onto heap, maintaining the heap invariant."""
134 heap.append(item)
138 """Pop the smallest item off the heap, maintaining the heap invariant."""
147 def heapreplace(heap, item):
148 """Pop and return the current smallest value, and add the new item.
152 returned may be larger than item! That constrains reasonable uses of
155 if item > heap[0]:
156 item = heapreplace(heap, item)
159 heap[0] = item
163 def heappushpop(heap, item):
165 if heap and heap[0] < item:
166 item, heap[0] = heap[0], item
168 return item
191 def _heapreplace_max(heap, item):
194 heap[0] = item