Deque

Deque

Class representing deque.
deque is implemented extends queue.
add additional method.
pop and push method of queue is assumed as private.
this constructor can get Queue type object.

Constructor

new Deque()

Version:
  • v1.0

Methods

front() → {boolen}

Get the first element of deque.

Returns:

the first data of deque.

Type
boolen

back() → {*}

Get the last element of deque.

Returns:
  • the last element of deque.
Type
*

empty() → {boolean}

Make sure the deque is empty.

Returns:

true if deque is empty.

Type
boolean

size() → {number}

Get the number of element in deque.

Returns:

the number of elements.

Type
number

clear()

Initalize the deque

pushBack(data)

add data to back of deque.

Parameters:
Name Type Description
data *

the data of deque.

pushFront(data)

add data to front of deque.

Parameters:
Name Type Description
data *

the data of deque.

popBack() → {boolean}

remove the last data of deque.

Returns:

if deque is empty, return false.

Type
boolean

popFront() → {boolean}

remove the first data of deque.

Returns:

if deque is empty, return false.

Type
boolean

compare(otherDeque) → {boolean}

compare data of this and param in order.

Parameters:
Name Type Description
otherDeque Deque

Deque object.

Returns:

Make sure this and param are same.

Type
boolean

toString() → {string}

show information of object

Returns:
Type
string

copy() → {Deque}

return a copy of this object.

Returns:
Type
Deque