Core operation for binary heaps, expressed directly on arrays.
Given an array which is a max-heap, push item i down to restore the max-heap property.
Instances For
O(1). Build a new empty heap.
Instances For
O(1). Build a one-element heap.
Instances For
O(1). Get the number of elements in a BinaryHeap.
Instances For
O(1). Get data vector of a BinaryHeap.
Instances For
O(1). Get an element in the heap by index.
Instances For
O(log n). Insert an element into a BinaryHeap, preserving the max-heap property.
Instances For
O(1). Get the maximum element in a BinaryHeap.
Instances For
O(log n). Remove the maximum element from a BinaryHeap.
Call max first to actually retrieve the maximum element.
Instances For
O(log n). Return and remove the maximum element from a BinaryHeap.
Instances For
O(log n). Equivalent to extractMax (self.insert x), except that extraction cannot fail.
Instances For
O(log n). Equivalent to (self.max, self.popMax.insert x).
Instances For
O(log n). Replace the value at index i by x. Assumes that x ≤ self.get i.
Instances For
O(log n). Replace the value at index i by x. Assumes that self.get i ≤ x.
Instances For
O(n). Convert an unsorted vector to a BinaryHeap.
Instances For
O(n). Convert an unsorted array to a BinaryHeap.