Queue Data-Structure for TypeScript
This is a queue data-structure implementation for TypeScript using a doubly linked-list from the package dl-doubly-linked-list
version 1.0.3 or greater.
Installation
npm install dl-queue-ts
API
Constructor
let q : Queue<T> = new Queue();
Properties
Name | Type | Description |
---|
length | number | Number of elements in the queue. |
Methods
Name | Param | Type | Description |
---|
clear | none | | Empties the queue. |
peek | index | number | Returns the element stored at the index position. Throws exception if index is out of bounds. |
pop | none | | Pops the top most emlement in the queue. |
push | element | T | Pushes an element of type T (generic) into the queue. |
Documentation
Please refer to doc/index.html
for the complete documentation and API reference. The documentation for this project was generated using Compodoc.
Demo
let q : Queue<number> = new Queue();
for(let i=0; i<10; i++) {
q.push(i*3);
}
let nums : Array<number|null> = queue.toArray();
let n : number = q.pop();
n = q.peek(3);
n = q.peek(33);
q.clear();