Class Heap<T>Abstract

Type Parameters

  • T = number

Hierarchy

Constructors

  • The function is a constructor for a class that initializes a priority callback function based on the options provided.

    Type Parameters

    • T = number

    Parameters

    • Optional options: HeapOptions<T>

      An optional object that contains configuration options for the Heap.

    Returns Heap<T>

Properties

_priorityCb: ((val) => number)

Type declaration

    • (val): number
    • Parameters

      • val: T

      Returns number

Accessors

Methods

  • The add function adds an val to a priority queue with an optional priority value.

    Parameters

    • val: T

      The val parameter represents the value that you want to add to the heap. It can be of any type.

    • Optional priority: number

      The 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

    Returns Heap<T>

    The add method returns the instance of the Heap class.

    Throws

    if priority is not a valid number

  • 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 PriorityQueue<HeapItem<T>>

  • 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 ((val) => number)

      • (val): number
      • Parameters

        • val: T

        Returns number

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

  • The function checks if a given node or value exists in the priority queue.

    Parameters

    • node: T | HeapItem<T>

      The parameter node can be of type T or HeapItem<T>.

    Returns boolean

    a boolean value.

  • The function checks if a priority queue is empty.

    Returns boolean

    A boolean value indicating whether the size of the priority queue is less than 1.

  • The peek function returns the top item in the priority queue without removing it.

    Returns null | HeapItem<T>

    The peek() method is returning either a HeapItem<T> object or null.Returns an val with the highest priority in the queue

  • The peekLast function returns the last item in the heap.

    Returns null | HeapItem<T>

    The method peekLast() returns either a HeapItem<T> object or null.Returns an val with the lowest priority in the queue

  • The poll function returns the top item from a priority queue or null if the queue is empty.Removes and returns an val with the highest priority in the queue

    Returns null | HeapItem<T>

    either a HeapItem object or null.

Generated using TypeDoc