Queue

Queue

Class representing queue.
Circular queue.
Use array as container.

Constructor

new Queue(data)

Version:
  • v1.0

Get none or iterable object and make queue. Can get Deque type object also.

Parameters:
Name Type Default Description
data null | Object null

Iterable object

Methods

front() → {false|*}

Get the first element of queue.

Returns:
  • the first element of queue. if queue is empty, return false.
Type
false | *

back() → {*}

Get the last element of queue.

Returns:
  • the last element of queue.
Type
*

empty() → {boolean}

Make sure the queue is empty.

Returns:

true if queue is empty.

Type
boolean

size() → {number}

Get the number of element in queue.

Returns:

the number of elements.

Type
number

clear()

Initalize the queue

push(data)

Insert new data to queue.

Parameters:
Name Type Description
data *

the element of queue.

pop() → {boolean}

remove a data of queue.

Returns:

If queue is empty, return false.

Type
boolean

compare(otherQueue) → {boolean}

Compare with other queue

Parameters:
Name Type Description
otherQueue Queue

Queue object.

Returns:

Make sure two queues are same.

Type
boolean

toString() → {string}

show information of object

Returns:
Type
string

copy() → {Queue}

return a copy of this object.

Returns:
Type
Queue