Queue

Queue

new Queue()

Create a FIFO queue data structure.
Source:

Methods

clear()

Clear the contents of the queue.
Source:

dequeue() → {object}

Get the front element of the queue and removes it from the queue.
Source:
Returns:
Front element from the queue.
Type
object

enqueue(obj)

Push an object in to the queue.
Parameters:
Name Type Description
obj object Any object to be pushed into the queue.
Source:

hasNext() → {boolean}

Checks if the queue isn't empty.
Source:
Returns:
Whether or not the queue has another element. True if yes.
Type
boolean

isEmpty() → {boolean}

Checks if the queue is empty.
Source:
Returns:
Whether or not the queue is empty. True if yes.
Type
boolean

peek() → {object}

Get the front element of the queue without removing it from the queue.
Source:
Returns:
Front element from the queue.
Type
object

size() → {number}

Get the number of objects in the queue.
Source:
Returns:
Number of elements in the queue.
Type
number