Options
All
  • Public
  • Public/Protected
  • All
Menu

The Queue class represents a first-in-first-out (FIFO) queue of generic elements. It supports the usual enqueue and dequeue operations, along with methods for peeking at the first item, testing if the queue is empty, and iterating through the items in FIFO order.

Type parameters

  • E

Hierarchy

  • Queue

Implemented by

Index

Methods

asCollection

  • Returns collection backed by this queue. Iterations will be in FIFO order. Time complexity is O(1).

    Returns Collection<E>

    collection of elements from this queue.

dequeue

  • dequeue(): E
  • Removes and returns the element on this queue that was least recently added.

    throws

    Error('Queue underflow') if this queue is empty.

    Returns E

    the element on this queue that was least recently added.

enqueue

  • enqueue(e: E): Queue<E>
  • Adds the element to this queue.

    Parameters

    • e: E

      element the item to add.

    Returns Queue<E>

    queue with the added element.

isEmpty

  • isEmpty(): boolean
  • Returns true if this queue is empty.

    Returns boolean

    true if this queue is empty; false otherwise

peek

  • peek(): E
  • Returns the element least recently added to this queue.

    throws

    Error('Queue underflow') if this queue is empty.

    Returns E

    the element least recently added to this queue.

size

  • size(): number
  • Returns the number of elements in this queue.

    Returns number

    the number of elements in this queue.

toString

  • toString(): string
  • Returns a string representation of this queue.

    Returns string

    the sequence of elements in FIFO order, separated by spaces.

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc