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