Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Queue

First in first out (FIFO) linear data structure

Examples

const { Queue } = require('dsajs');
// or
// import { Queue } from 'dsajs';

let q = new Queue();

Hierarchy

  • Queue

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

  • new Queue(arr?: any[]): Queue
  • throws

    Will throw an error if the argument is provided and is not an arry

    Parameters

    • arr: any[] = []

      optional array to initialize queue

    Returns Queue

Properties

Private _

_: any[]

Accessors

size

  • get size(): number

Methods

dequeue

  • dequeue(): any
  • Get the first element from the queue

    Returns any

    the first element from the queue or undefined if queue is empty

enqueue

  • enqueue(element: any): void

isEmpty

  • isEmpty(): boolean

peek

  • peek(): any
  • Peek the first element of queue without removing it

    Returns any

    an element from the queue or undefined if queue is empty

Generated using TypeDoc