Queue

new Queue()

A queue that can enqueue items at the end, and dequeue items from the front.

Members

length

The length of the queue.

Methods

clear()

Remove all items from the queue.

contains(item)

Check whether this queue contains the specified item.
Name Type Description
item Object the item to search for.

dequeue()

Dequeues an item. Returns undefined if the queue is empty.

enqueue(item)

Enqueues the specified item.
Name Type Description
item Object The item to enqueue.

sort(compareFunction)

Sort the items in the queue in-place.
Name Type Description
compareFunction function a function that defines the sort order.