Class AbstractHeap<N>Abstract

An abstract class representing a heap.

Type Parameters

Hierarchy (View Summary)

Constructors

Accessors

Methods

  • Returns an iterator for traversing the heap.

    Parameters

    • reversed: boolean

      If true, the iterator will traverse the heap in reverse order.

    Returns Generator<N, void, void>

    A generator that yields N type elements.

  • Decreases the key value of a heap element.

    Parameters

    • node: N

      The element whose key value will be decreased.

    • decreaseValue: N["key"]

      The value of decrease.

    Returns boolean

    true or false depending on the outcome of the decrease process.

  • Returns an iterator for traversing the heap elements.

    Parameters

    • reversed: boolean

      If true, the iterator will traverse the heap in reverse order.

    Returns Generator<N, void, void>

  • Executes a provided function (callbackFn) once per element in the heap.

    Parameters

    • callbackFn: (node: N, index: number, heapInstance: AbstractHeap<N>) => void
        • (node: N, index: number, heapInstance: AbstractHeap<N>): void
        • Parameters

          • node: N

            Element of each iteration.

          • index: number

            The index of the current element being processed in the heap.

          • heapInstance: AbstractHeap<N>

            The heap instance being iterated.

          Returns void

    • OptionalthisArg: any

      A value to use as this when executing callbackFn.

    Returns void

  • Increases the key value of a heap element.

    Parameters

    • node: N

      The element whose key value will be increased.

    • increaseValue: N["key"]

      The value of increase.

    Returns boolean

    true or false depending on the outcome of the increase process.

  • Returns an iterator for traversing the heap element keys.

    Parameters

    • reversed: boolean

      If true, the iterator will traverse the heap in reverse order.

    Returns Generator<N["key"], void, void>

  • Removes and returns the top element of the heap, or returns undefined if the heap is empty.

    Returns undefined | N

  • Removes a node from the heap.

    Parameters

    • node: N

      The node to remove.

    Returns boolean

    true or false depending on the outcome of the removal process.