Queue
elements data type: any type.
Usage
const pQueueFn = require('@datastructures-js/priority-queue');
const pQueue = pQueueFn();
API
.enqueue(element, priority)
adds an element with priority (number) to the back of the queue.
pQueue.enqueue('patient 1', 2);
pQueue.enqueue('patient 2', 1);
.front()
returns the front element in queue.
console.log(pQueue.front());
.back()
returns the back element in the queue.
console.log(pQueue.back());
.dequeue()
dequeues the highest priority element from the queue.
console.log(pQueue.dequeue());
console.log(pQueue.front());
.isEmpty()
checks if the queue is empty.
console.log(pQueue.isEmpty());
.length()
returns the length of the queue.
console.log(pQueue.length());
.toArray()
converts the queue to an array from highest prority element to lowest
pQueue.enqueue('patient 3', 5);
pQueue.enqueue('patient 4', 1);
console.log(pQueue.toArray());
.clear()
clears the queue
pQueue.clear();
console.log(pQueue.length());
Build
grunt build
License
The MIT License. Full License is here