• Home
  • Raw
  • Download

Lines Matching refs:heap

130 def heappush(heap, item):  argument
132 heap.append(item)
133 _siftdown(heap, 0, len(heap)-1)
135 def heappop(heap): argument
137 lastelt = heap.pop() # raises appropriate IndexError if heap is empty
138 if heap:
139 returnitem = heap[0]
140 heap[0] = lastelt
141 _siftup(heap, 0)
145 def heapreplace(heap, item): argument
156 returnitem = heap[0] # raises appropriate IndexError if heap is empty
157 heap[0] = item
158 _siftup(heap, 0)
161 def heappushpop(heap, item): argument
163 if heap and heap[0] < item:
164 item, heap[0] = heap[0], item
165 _siftup(heap, 0)
179 def _heappop_max(heap): argument
181 lastelt = heap.pop() # raises appropriate IndexError if heap is empty
182 if heap:
183 returnitem = heap[0]
184 heap[0] = lastelt
185 _siftup_max(heap, 0)
189 def _heapreplace_max(heap, item): argument
191 returnitem = heap[0] # raises appropriate IndexError if heap is empty
192 heap[0] = item
193 _siftup_max(heap, 0)
205 def _siftdown(heap, startpos, pos): argument
206 newitem = heap[pos]
211 parent = heap[parentpos]
213 heap[pos] = parent
217 heap[pos] = newitem
258 def _siftup(heap, pos): argument
259 endpos = len(heap)
261 newitem = heap[pos]
267 if rightpos < endpos and not heap[childpos] < heap[rightpos]:
270 heap[pos] = heap[childpos]
275 heap[pos] = newitem
276 _siftdown(heap, startpos, pos)
278 def _siftdown_max(heap, startpos, pos): argument
280 newitem = heap[pos]
285 parent = heap[parentpos]
287 heap[pos] = parent
291 heap[pos] = newitem
293 def _siftup_max(heap, pos): argument
295 endpos = len(heap)
297 newitem = heap[pos]
303 if rightpos < endpos and not heap[rightpos] < heap[childpos]:
306 heap[pos] = heap[childpos]
311 heap[pos] = newitem
312 _siftdown_max(heap, startpos, pos)