Queue

DataStructure. Queue

Queue which is complimentary to stacks. The difference is that this time you remove items from the start of the queue rather than the end. Removing the oldest items rather than the most recent.

Constructor

new Queue()

Start with an empty array and store the length of the "queue". Note that we to store the length separately because the "memory" doesn't have a length that can be read.
Source:

Methods

dequeue() → {*}

Instead of removing the item from the end of the list, we're going to remove it from the start.
Source:
Returns:
Type
*

enqueue(value)

Push values to the end of the list.
Parameters:
Name Type Description
value * Value that should be added to the list
Source:

peek() → {*}

Getting the next value without removing it from the stack.
Source:
Returns:
Type
*