AdaptableHeapPriorityQueue
Container of elements which grants access to the least item stored in logarithmic time. Insertion operation has logarithmic complexity as well.
new AdaptableHeapPriorityQueue()
/**
* Creates an instance of AdaptableHeapPriorityQueue.
*
* @param elements List of elements to create the new priority queue with.
* @param compare Comparison function for element search. Elements are compared as numbers by default.
*/
constructor(elements: K[] | [K, V][] = [], protected compare: CompareFunc<K> = compareAsNumbers)length
length: numberNumber of elements in the queue. This field is read only.
Examples:
import { SortedPriorityQueue } from 'ads-js/queues';
const queue = new SortedPriorityQueue();
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:
remove()
update()
Last updated
Was this helpful?