m3sh.heap.Heap.
from_list#
- classmethod Heap.from_list(items)#
Initialize heap from list.
Turns items into a heap-ordered binary tree and uses it directly as internal storage.
- Parameters:
- itemslist
A list of (obj, key) tuples.
- Returns:
- heapHeap
Heap that uses items directly as storage. Subsequent external modification of items will destroy the heap property.
Notes
The heap generated via
Heap.from_list(items)does not duplicate data storage. It may be preferable toHeap(items)in some use cases.