Optional
options: Omit<PriorityQueueOptions<number>, "comparator">The options
parameter is an optional object that can contain various configuration options for
the PriorityQueue
constructor.
The constructor initializes a priority queue with an optional comparator function.
The options
parameter is an optional object that can contain various configuration options for
the PriorityQueue
constructor.
Protected
Readonly
_comparatorProtected
_nodesThe DFS function performs a depth-first search traversal on a binary tree and returns an array of visited nodes based on the specified traversal order.
The dfsMode parameter is a string that specifies the order in which the nodes should be visited during the Depth-First Search (DFS) traversal. It can have one of the following values:
an array of type (T | null)[]
.
Protected
_compareThe function compares two numbers using a custom comparator function.
The parameter "a" is a number that represents the index of a node in an array.
The parameter "b" is a number.
the result of the comparison between the elements at indices a
and b
in the nodes
array. The
comparison is done using the _comparator
function, and if the result is greater than 0, true
is returned,
indicating that the element at index a
is greater than the element at index b
.
Protected
_fixProtected
_getThe function returns the index of the smallest child node of a given parent node.
The parent parameter is a number that represents the index of the parent node in a binary tree.
the minimum value between the parent node and its left and right child nodes.
Protected
_getThe function returns the index of the left child node in a binary tree given the index of its parent node.
The parameter "parent" is a number that represents the index of a node in a binary tree.
the left child of a given parent node in a binary tree.
Protected
_getProtected
_getThe function returns the index of the right child node in a binary tree given the index of its parent node.
The parameter "parent" is a number that represents the index of a node in a binary tree.
the right child of a given parent node in a binary tree.
Protected
_heapifyProtected
_heapifyProtected
_isThe function checks if a given index is valid within an array.
The parameter "index" is of type number and represents the index value that needs to be checked for validity.
A boolean value indicating whether the given index is valid or not.
Protected
_setProtected
_swapThe clone
function returns a new instance of the PriorityQueue
class with the same nodes and comparator as the
original instance.
The clone()
method is returning a new instance of the PriorityQueue
class with the same nodes
and
comparator
properties as the original instance.
Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
The "has" function checks if a given node is present in the list of nodes.
The parameter node
is of type T
, which means it can be any type. It represents the node that
we want to check if it exists in the nodes
array.
a boolean value indicating whether the given node is included in the array of nodes.
Static
heapifyThe function heapify
creates a new MinPriorityQueue instance and sets the comparator function based on the options
provided, and then fixes the heap structure of the queue.
Optional
options: Omit<PriorityQueueOptions<T>, "comparator">The options
parameter is an object that contains configuration options for creating a priority
queue. It can have the following properties:
a MinPriorityQueue object.
The function heapify
creates a new MinPriorityQueue instance and sets the comparator function based on the options
provided, and then fixes the heap structure of the queue.
The options
parameter is an object that contains configuration options for creating a priority
queue. It can have the following properties:
a MinPriorityQueue object.
Static
isThe function checks if a priority queue is valid by creating a new priority queue with a fix option and then calling the isValid method.
An object containing options for creating a priority queue. The options object should have the following properties:
the result of calling the isValid()
method on a new instance of the PriorityQueue
class.
Generated using TypeDoc
The constructor initializes a priority queue with an optional comparator function.