PriorityQueue<T> Class

A priority queue implemented as a heap array. The queue is ordered by an OrderedComparator function supplied by the user such that the value in the queue that compares less than all other values is always located at the front of the queue.

Implements

  • Iterable<T>

Methods

Name Description
constructor(compare: OrderedComparator<T>, clone: CloneFunction<T> = shallowClone): PriorityQueue Constructor  
__@iterator(): Iterator<T> Returns an iterator over the contents of the heap suitable for use in for-of loops.  
_heapify(index: number): void Protected    
_peek(index: number): T | undefined Protected Returns the value at the specified index in the queue.  
_pop(index: number): T | undefined Protected Removes the value at the specified index from the queue and reorders the queue.  
_swap(a: number, b: number): void Protected    
append(value: T): T Pushes a value onto the back of the queue without making any attempt to enforce ordering.  
clear(): void Removes all values from the queue.  
pop(): T | undefined Removes the front-most element off of the queue and returns it.  
push(value: T): T Pushes a value onto the queue according to the sorting criterion.  
sort(): void Reorders the queue.  

Properties

Name Type Description
_array Protected T[]    
_clone Protected CloneFunction<T>    
_compare Protected OrderedComparator<T>    
front Accessor ReadOnly T | undefined Returns the element at the front of the queue, or undefined if the queue is empty.  
isEmpty Accessor ReadOnly boolean Returns true if the queue contains no values.  
length Accessor ReadOnly number The number of values in the queue.  

Defined in

Last Updated: 20 September, 2019