LinkedQueue
Container of elements that are inserted and removed according to the FIFO principle. This structure is based on SinglyLinkedList.
new LinkedQueue()
/**
* Creates an instance of LinkedQueue.
*
* @param elements List of elements to create the new queue with.
*/
constructor(elements: T[] = [])length
length: numberNumber of elements in the queue. This field is read only.
Examples:
import { LinkedQueue } from 'ads-js/queues';
const queue = new LinkedQueue();
queue.length === 0; // true
queue.enqueue(1);
queue.length === 1; // trueclear()
dequeue()
enqueue()
getFirst()
isEmpty()
Running time O(1)
Checks whether the queue is empty or not.
Returns:
TRUE if the queue is empty, FALSE otherwise.
Examples:
Last updated
Was this helpful?