Class MinPriorityQueue<E>

Type Parameters

  • E = any

Hierarchy

Constructors

Properties

_comparator: PriorityQueueComparator<E> = ...
_nodes: E[] = []

Accessors

Methods

  • The 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.

    Parameters

    • dfsMode: PriorityQueueDFSOrderPattern

      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:

    Returns (null | E)[]

    an array of type (E | null)[].

  • The function compares two numbers using a custom comparator function.

    Parameters

    • a: number

      The parameter "a" is a number that represents the index of a node in an array.

    • b: number

      The parameter "b" is a number.

    Returns boolean

    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.

  • The function returns the index of the smallest child node of a given parent node.

    Parameters

    • parent: number

      The parent parameter is a number that represents the index of the parent node in a binary tree.

    Returns number

    the minimum value between the parent node and its left and right child nodes.

  • The function returns the index of the left child node in a binary tree given the index of its parent node.

    Parameters

    • parent: number

      The parameter "parent" is a number that represents the index of a node in a binary tree.

    Returns number

    the left child of a given parent node in a binary tree.

  • The function returns the index of the parent node given the index of a child node in a binary tree.

    Parameters

    • child: number

      The "child" parameter is a number representing the index of a child node in a binary tree.

    Returns number

    the parent of the given child node.

  • The function returns the index of the right child node in a binary tree given the index of its parent node.

    Parameters

    • parent: number

      The parameter "parent" is a number that represents the index of a node in a binary tree.

    Returns number

    the right child of a given parent node in a binary tree.

  • The function checks if a given index is valid within an array.

    Parameters

    • index: number

      The parameter "index" is of type number and represents the index value that needs to be checked for validity.

    Returns boolean

    A boolean value indicating whether the given index is valid or not.

  • The "add" function adds a node to the heap and ensures that the heap property is maintained.

    Parameters

    • node: E

      The parameter "node" is of type E, which means it can be any data type. It represents the node that needs to be added to the heap.

    Returns void

  • 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.

    Returns E[]

  • The "has" function checks if a given node is present in the list of nodes.

    Parameters

    • node: E

      The parameter node is of type E, which means it can be any type. It represents the node that we want to check if it exists in the nodes array.

    Returns boolean

    a boolean value indicating whether the given node is included in the array of nodes.

  • The function checks if the size of an object is equal to zero and returns a boolean value indicating whether the object is empty or not.

    Returns boolean

    The method isEmpty() is returning a boolean value indicating whether the size of the object is equal to 0.

  • The leaf function returns the last element in the nodes array or null if the array is empty.

    Returns null | E

    The method leaf() is returning the last element (E) in the nodes array if it exists. If the array is empty or the last element is null, then it returns null.

  • The peek function returns the first element of the nodes array if it exists, otherwise it returns null.

    Returns null | E

    The peek() function is returning the first element (E) of the nodes array if the size is not zero. Otherwise, it returns null.

  • The function checks if a priority queue is valid by creating a new priority queue with a fix option and then calling the isValid method.

    Type Parameters

    • E

    Parameters

    • options: Omit<PriorityQueueOptions<E>, "isFix">

      An object containing options for creating a priority queue. The options object should have the following properties:

    Returns boolean

    the result of calling the isValid() method on a new instance of the PriorityQueue class.

Generated using TypeDoc