LinkedDeque
Container of elements that are inserted and removed on either side. This structure is based on DoublyLinkedList.
new LinkedDeque()
/**
* Creates an instance of LinkedDeque.
*
* @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 { LinkedDeque } from 'ads-js/queues';
const queue = new LinkedDeque();
queue.length === 0; // true
queue.enqueue(1);
queue.length === 1; // trueclear()
dequeue()
dequeLast()
enqueue()
enqueueFirst()
getFirst()
getLast()
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?