Interface representing a generic PriorityQueue ADT.

interface PriorityQueue<T> {
    size: number;
    clear(): void;
    dequeue(): undefined | T;
    enqueue(item: T, priority: number): void;
    isEmpty(): boolean;
    peek(): undefined | T;
}

Type Parameters

  • T

Hierarchy

  • QueueBase<T>
    • PriorityQueue

Implemented by

Properties

Methods

Properties

size: number

Gets the number of elements in the collection.

Methods

  • Removes and returns the element from the queue

    Returns undefined | T

    returns the element from the queue.

  • Adds an element to the queue with a given priority

    Parameters

    • item: T

      The element to add.

    • priority: number

      The priority of item.

    Returns void

  • Returns true if the collection is empty.

    Returns boolean

    True if the collection is empty, otherwise false.

  • Returns the element from the queue without removing it

    Returns undefined | T

    returns the element from the queue without removing it.