BinaryHeap
This is a class I took from something Rust related. You can read its documentation info here.
Properties
ComparisonFunction
BinaryHeap.ComparisonFunction: ComparisonFunction<Comparable>?The ComparisonFunction of the BinaryHeap.
Length
BinaryHeap.Length: intThe Length of the BinaryHeap.
Functions
new
BinaryHeap.new(ComparisonFunction:Â ComparisonFunction<Comparable>?--
The comparison function.
) → BinaryHeap<T>Creates a new BinaryHeap.
Push
BinaryHeap:Push(Key:Â Comparable--
The key you are pushing. Must be able to work with comparing methods like <.
) → int--
The index of the pushed key in the heap.
Pushes a new key to the heap.
Pop
BinaryHeap:Pop() → Comparable?--
The minimum element if it exists, otherwise nil.
Removes the minimum element (the root) from the heap and returns it.
Delete
BinaryHeap:Delete(Index:Â int--
The index of the key you want to delete.
) → BinaryHeap<T>--
Returns the same heap.
Deletes the key at Index by shifting it to root (treating it as -infinity) and then popping it.
GetFront
BinaryHeap:GetFront() → T--
The first value.
Returns the front value of the heap.
IsEmpty
BinaryHeap:IsEmpty() → boolean-Trueifftheheapisempty.Determines if the heap is empty.