Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PriorityQueue<T>

Type parameters

Hierarchy

Index

Constructors

constructor

Accessors

invertPriority

  • get invertPriority(): boolean
  • set invertPriority(val: boolean): void
  • Get/Set whether this queue has inverted priority or not. False: smallest values will be at the front of the queue. True: largest values will be at the front of the queue. False by default. Setting the value will cause the queue to be reordered.

    property

    {boolean}

    Returns boolean

  • Get/Set whether this queue has inverted priority or not. False: smallest values will be at the front of the queue. True: largest values will be at the front of the queue. False by default. Setting the value will cause the queue to be reordered.

    property

    {boolean}

    Parameters

    • val: boolean

    Returns void

length

  • get length(): number

Methods

clear

  • clear(): void

contains

  • contains(element: T): boolean
  • Returns whether the item exists in the queue.

    Parameters

    • element: T

      The element to search for.

    Returns boolean

    True if the element is in the queue; false otherwise.

extractMax

  • extractMax(): T
  • Removes and returns the item at the front of the queue

    Returns T

    The item at the front of the queue.

filter

  • filter(queryCallback: (el: T) => boolean): T[]
  • Retrieve elements that match a query.

    Parameters

    • queryCallback: (el: T) => boolean

      A callback that returns whether an element matches

        • (el: T): boolean
        • Parameters

          • el: T

          Returns boolean

    Returns T[]

    The element if found; null otherwise.

getByIndex

  • getByIndex(i: number): T
  • Retrieve the element at a specified index. Throws an error if i is out of bounds.

    Parameters

    • i: number

      The index of the target element

    Returns T

    The element found at the specified index.

indexOf

  • indexOf(element: T): number
  • Returns the index of the item if it exists in the queue.

    Parameters

    • element: T

      The element to search for.

    Returns number

    The index of the element in the queue; -1 if it does not exist.

insert

  • insert(element: T): void
  • Adds a new item to the queue.

    Parameters

    • element: T

      The item to be added to the queue. Must implement Comparable.

    Returns void

peek

  • peek(): T
  • Retrieve the element at the front of the queue.

    Returns T

    The element at the front of the queue.

poll

  • poll(): T
  • Removes and returns the item at the front of the queue

    method

    Returns T

    The item at the front of the queue.

pop

  • pop(): T
  • Removes and returns the item at the front of the queue

    method

    Returns T

    The item at the front of the queue.

push

  • push(element: T): void
  • Adds a new item to the queue.

    method

    Parameters

    • element: T

      The item to be added to the queue. Must implement Comparable.

    Returns void

remove

  • remove(element: T): void
  • Parameters

    • element: T

      The element to be removed from the list.

    Returns void

setInvertPriority

  • setInvertPriority(bool: boolean): void
  • Set whether this queue has inverted priority or not. False: smallest values will be at the front of the queue. True: largest values will be at the front of the queue. False by default. Setting the value will cause the queue to be reordered.

    Parameters

    • bool: boolean

      The value to set

    Returns void

size

  • size(): number

toSortedArray

  • toSortedArray(): T[]

updateElement

  • updateElement(element: T): void
  • Used to update the queue when a element's priority has been changed. Assumes the element has already been inserted. Assumes you have updated the value on your own.

    Parameters

    • element: T

      The element to update

    Returns void

Generated using TypeDoc