This module provides an abstract class for any Queue data structure.
For convenience, the underlying queue API is fairly close to the regular JS array API.
The submodules contain different classes and interfaces that extends or implements that class.
The main module re-exports these implementations:
For convenience, the underlying queue API is fairly close to the regular JS array API.
That is, you have methods for adding and removing elements: push/unshift and pop/shift.
Notice, the shift and unshift methods just aliases for pop and push.
core/queue
This module provides an abstract class for any Queue data structure. For convenience, the underlying queue API is fairly close to the regular JS array API.
The submodules contain different classes and interfaces that extends or implements that class. The main module re-exports these implementations:
AbstractQueue
— an alias forcore/queue/interface/Queue
;AbstractWorkerQueue
— an alias forcore/queue/worker/interface/WorkerQueue
;Queue
— an alias forcore/queue/simple
;OrderedQueue
— an alias forcore/queue/order
;MergeQueue
— an alias forcore/queue/merge
.AbstractWorkerQueue
— an alias forcore/queue/worker
.WorkerQueue
— an alias forcore/queue/worker/simple
.MergeWorkerQueue
— an alias forcore/queue/worker/merge
.API
Own API
head
The first element in the queue.
clone
Creates a new queue based on the current one and returns it.
clear
Clears the queue.
Array-Like API
For convenience, the underlying queue API is fairly close to the regular JS array API.
That is, you have methods for adding and removing elements:
push/unshift
andpop/shift
. Notice, theshift
andunshift
methods just aliases forpop
andpush
.You can also find out the number of elements in the queue using the
length
getter.Like arrays, any queue can be traversed using an iterator.
In addition, the API declares
head
to get the first element from the queue andclear
to clear the queue.Simple implementation