DeQueue

DeQueue

Custom implementation of a double ended queue.

Constructor

new DeQueue(array)

Source:
Parameters:
Name Type Description
array Array.<any>

Members

length

Source:

alias for this.size()

Methods

clear()

Source:

Soft clear - does not reset capacity.

dequeue()

Source:

Alias for shift()

enqueue()

Source:

Alias for push()

get(i) → {*}

Source:

Alias for peakAt()

Parameters:
Name Type Description
i
Returns:
Type
*
Source:

Alias for peek()

Returns:
Type
*

isEmpty() → {boolean}

Source:

Returns true or false whether the list is empty.

Returns:
Type
boolean

peek() → {*}

Source:

Returns the first item in the list without removing it.

Returns:
Type
*

peekAt(index) → {*}

Source:

Returns the item at the specified index from the list.
0 is the first element, 1 is the second, and so on...
Elements at negative values are that many from the end: -1 is one before the end
(the last element), -2 is two before the end (one before last), etc.

Parameters:
Name Type Description
index
Returns:
Type
*

peekBack()

Source:

Returns the item that is at the back of the queue without removing it.
Uses peekAt(-1)

peekFront() → {*}

Source:

Alias for peek()

Returns:
Type
*

pop() → {*}

Source:

Remove and return the last item on the list.
Returns undefined if the list is empty.

Returns:
Type
*

push(item)

Source:

Add an item to the bottom of the list.

Parameters:
Name Type Description
item

remove(index, count) → {array}

Source:

Remove number of items from the specified index from the list.
Returns array of removed items.
Returns undefined if the list is empty.

Parameters:
Name Type Description
index
count
Returns:
Type
array

removeOne(index) → {*}

Source:

Remove and return the item at the specified index from the list.
Returns undefined if the list is empty.

Parameters:
Name Type Description
index
Returns:
Type
*

set(index, value) → {*}

Source:

Sets the queue value at a particular index

Parameters:
Name Type Description
index number

integer

value *
Returns:
Type
*

shift() → {*}

Source:

Remove and return the first item on the list
Returns undefined if the list is empty.

Returns:
Type
*

size() → {number}

Source:

Return the number of items on the list, or 0 if empty.

Returns:
Type
number

splice(index, count, …args) → {array}

Source:

Native splice implementation.
Remove number of items from the specified index from the list and/or add new elements.
Returns array of removed items or empty array if count == 0.
Returns undefined if the list is empty.

Parameters:
Name Type Attributes Description
index
count
args Array.<*> <repeatable>
Returns:
Type
array

tail() → {*}

Source:

Alias for peekBack()

Returns:
Type
*

toArray() → {Array}

Source:

Returns an array of all queue items.

Returns:
Type
Array

unshift(item)

Source:

Add an item at the beginning of the list.

Parameters:
Name Type Description
item