Optional
options: HeapOptions<T>The options
parameter is an optional object that can be passed to the constructor. It is of
type HeapOptions<T>
, which is a generic type that represents the options for the heap.
Protected
_pqProtected
_priorityThe function returns the size of a priority queue.
The size of the priority queue.
The add
function adds an val to a priority queue with an optional priority value.
Optional
priority: numberThe priority
parameter is an optional number that represents the priority of the
val being added to the heap. If the val
parameter is a number, then the priority
parameter is set to
the value of val
. If the val
parameter is not a number, then the
Optional
val: TThe val
parameter represents the value that you want to add to the heap. It can be of any
type.
The add
method returns the instance of the Heap
class.
if priority is not a valid number
The function checks if a given node or value exists in the priority queue.
The parameter node
can be of type T
or HeapItem<T>
.
a boolean value.
Generated using TypeDoc
The constructor initializes a PriorityQueue with a comparator function that compares the priority of two HeapItem objects.