Queue typed similar to a std::queue with possibility to limit the capacity like a FIFO

Example

const queue = new Queue<number>(2);
queue.push(1); // [1]
queue.push(2); // [1,2]
queue.push(3); // [2,3] 1 has been removed to respect 2 capacity

Type Parameters

  • Type

Hierarchy

Constructors

Properties

Accessors

Methods

Constructors

  • Instanciate a new queue object with the type passed as template

    Type Parameters

    • Type

    Parameters

    • Optional capacity: number

      if set it limits the size of the queue, any exceding element pops the first element pushed (FIFO)

    Returns Queue<Type>

Properties

_capacity?: any
_queue: any

Accessors

  • get back(): Type
  • The back element

    Returns Type

  • get capacity(): undefined | number
  • Maximum capacity for the queue, if not set queue has unlimited capacity

    Returns undefined | number

  • set capacity(value): void
  • Set a maximum capacity for the queue, if you push new value exceding this capacity the firsts are removed (FIFO) if set to undefined the queue is unlimited

    Parameters

    • value: undefined | number

    Returns void

  • get front(): Type
  • The front element

    Returns Type

  • get size(): number
  • Number of element in the queue

    Returns number

Methods

  • Iterator though queue's elements

    Returns IterableIterator<Type>

  • Clear all the elements, queue becomes empty

    Returns Queue<Type>

    this

  • Pop the first element from the queue

    Returns undefined | Type

    The first element removed

  • Push a new element in the queue

    Parameters

    • value: Type

      value of the element

    Returns Queue<Type>

    this

Generated using TypeDoc