MCPcopy Create free account
hub / github.com/python/cpython / create_heap

Method create_heap

Lib/test/test_free_threading/test_heapq.py:224–236  ·  view source on GitHub ↗

Create a min/max heap where elements are in the range (0, size - 1) and shuffled before heapify.

(size, heap_kind)

Source from the content-addressed store, hash-verified

222
223 @staticmethod
224 def create_heap(size, heap_kind):
225 """
226 Create a min/max heap where elements are in the range (0, size - 1) and
227 shuffled before heapify.
228 """
229 heap = list(range(OBJECT_COUNT))
230 shuffle(heap)
231 if heap_kind == Heap.MIN:
232 heapq.heapify(heap)
233 else:
234 heapq.heapify_max(heap)
235
236 return heap
237
238 @staticmethod
239 def create_random_list(a, b, size):

Calls 1

listClass · 0.85

Tested by

no test coverage detected