Lines Matching refs:heap
33 heap = []
35 self.check_invariant(heap)
39 self.module.heappush(heap, item)
40 self.check_invariant(heap)
42 while heap:
43 item = self.module.heappop(heap)
44 self.check_invariant(heap)
59 def check_invariant(self, heap): argument
61 for pos, item in enumerate(heap):
64 self.assertTrue(heap[parentpos] <= item)
68 heap = [random.random() for dummy in range(size)]
69 self.module.heapify(heap)
70 self.check_invariant(heap)
76 heap = []
78 self.module.heappush(heap, item)
79 if len(heap) > 10:
80 self.module.heappop(heap)
81 heap.sort()
82 self.assertEqual(heap, sorted(data)[-10:])
84 def heapiter(self, heap): argument
88 yield self.module.heappop(heap)
99 heap = data[:10]
100 self.module.heapify(heap)
102 if item > heap[0]: # this gets rarer the longer we run
103 self.module.heapreplace(heap, item)
104 self.assertEqual(list(self.heapiter(heap)), sorted(data)[-10:])
112 heap = data[:10]
113 self.module.heapify(heap)
115 self.module.heappushpop(heap, item)
116 self.assertEqual(list(self.heapiter(heap)), sorted(data)[-10:])
144 heap = data[:]
145 self.module.heapify(heap)
147 heap = []
149 self.module.heappush(heap, item)
150 heap_sorted = [self.module.heappop(heap) for i in range(size)]
342 def __init__(self, value, heap): argument
344 self.heap = heap
347 self.heap[:] = []
404 heap = []
405 heap.extend(SideEffectLT(i, heap) for i in range(200))
408 self.module.heappush(heap, SideEffectLT(5, heap))
411 heap = []
412 heap.extend(SideEffectLT(i, heap) for i in range(200))
415 self.module.heappop(heap)