Class: LinkedDeque

LinkedDeque

A Deque using linked nodes instead of standard javascript Array. In addition the Deque can be optionally capacity constrained, if unspecified, the value is set to Number.MAX_VALUE. Standard javascript Array's shift, unshift, push and pop operations are implemented for linked nodes.

Reference: LinkedBlockingDeque in Oracle JDK

new LinkedDeque(capacity)

Example -

var LinkedDeque = require("dsjslib").LinkedDeque
var ldq=new LinkedDeque(100)
Parameters:
Name Type Argument Description
capacity Number <optional>

set to Number.MAX_VALUE if not provided

Source:

Members

offerFirst

Equivalent to LinkedDeque#unshift

Source:

offerLast

Equivalent to LinkedDeque#push

Source:

pollFirst

Equivalent to LinkedDeque#shift

Source:

pop

Equivalent to LinkedDeque#pollLast

Source:

Methods

clear()

Removes all elements from the deque

Source:

pollLast() → {*}

Returns and removes the element at the tail of the Deque. Returns null if there is no such element Equivalent to LinkedDeque#pop

Source:
Returns:

Returns and removes the element at the tail of the Deque, null if no such element

Type
*

push() → {Boolean}

Add item to the tail of the Deque. Equivalent to ldq.offerLast(item). Returns true if obj was successfully added, false if it failed (for example, if the Deque is at full capacity.

Source:
Returns:

true if obj was successfully added, false otherwise

Type
Boolean

shift() → {*}

Returns and removes the element at the head of the Deque. Returns null if there is no such element Equivalent to LinkedDeque#pollFirst

Source:
Returns:

Returns and removes the element at the head of the Deque, null if no such element

Type
*

size() → {Number}

Source:
Returns:

size of the array

Type
Number

toArray() → {Array}

Returns an array containing all of the elements in this Deque, in proper sequence (from first to last element). The returned array has no links/pointers to the Deque. No items are removed from the Deque

Source:
Returns:
Type
Array

unshift() → {Boolean}

Add item to the head of the Deque. Equivalent to ldq.offerFirst(item). Returns true if obj was successfully added, false if it failed (for example, if the Deque is at full capacity.

Source:
Returns:

true if obj was successfully added, false otherwise

Type
Boolean