1.0.1 • Published 6 years ago

array-deque v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

ArrayDeque

Array-backed implementation of a deque. Supports O(1) random access, and amortized O(1) insertion and removal at the front and back of the deque

Kind: global class

new ArrayDeque(initSize, x)

Creates a new deque with size = initSize, and initializes elements to x. If no initSize is provided, returns a deque with size = 0

Param
initSize
x

arrayDeque.push_front(x)

Inserts x at the front / beginning of the deque

Kind: instance method of ArrayDeque

Param
x

arrayDeque.set(i, x) ⇒ *

Sets the ith element to x, returns the previous ith element. Returns undefined if index is out of range ( i < 0 || i >= deque.size)

Kind: instance method of ArrayDeque
Returns: * - Previous element at i

ParamDescription
iIndex of the element to set
xThe value that should be set

arrayDeque.push_back(x)

Inserts x at the back / end of the deque

Kind: instance method of ArrayDeque

Param
x

arrayDeque.pop_front() ⇒ *

Removes and returns the first element in the deque or undefined if there aren't any elements in the deque

Kind: instance method of ArrayDeque
Returns: * - First element in the deque

arrayDeque.pop_back() ⇒ *

Removes and returns the last element in the deque or undefined if there aren't any elements in the deque

Kind: instance method of ArrayDeque
Returns: * - Last element in the deque

arrayDeque.toArray() ⇒ Array.<any>

Returns an array containing the elements of the deque

Kind: instance method of ArrayDeque