Package Exports
- other-queue
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (other-queue) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Queue
Implementation of a queue (...based on arrays) in JavaScript in first-in-first-out order.
Install
git clone https://github.com/ahadb/queue
, create a tarball, or use directly for now
NPM:
To be published on NPM soon
Use
To be published on NPM soon
API
Constructor & Instance
const queue = new Queue();
queue.enqueue
Add an element to the queue
const queue = new Queue();
queue.enqueue('i_am_message_1');
queue.enqueue('i_am_message_2');
queue.dequeue
Dequeue, or remove an element from the queue
const queue = new Queue();
queue.dequeue('i_am_message_1');
queue.peek
See who is next in line
const queue = new Queue();
queue.enqueue('i_am_message_1');
queue.peek();
queue.getLength
Get the length of the queue
const queue = new Queue();
queue.getLength()
queue.toString
String representation of queue
const queue = new Queue();
queue.toString()
queue.isEmpty
Check if queue is empty
const queue = new Queue();
queue.isEmpty();
LinkedList.find
Find a node by value in your Singly Linked List.
On Creating Your Own Data Structures
Note: you can create your data structures without using arrays as well, or even use my linked-list.
// using plain ole prototype not syntactic class
const Queue = function() {
this.first = null;
this.size = 0;
};
const QueueNode = function(data) {
this.data = data;
this.next = null;
};
Queue.prototype.enqueue = function(data) {
const enqueuedNode = QueueNode(data)
// ..
};
Queue.prototype.dequeue = function() {
// ..
};