PriorityQueue(compare)

Class for representing a binary heap priority queue that enables more efficient sorting of arrays. The implementation is based on tinyqueue.

new PriorityQueue(compare)

Constructs a new priority queue.

Parameters:
Name Type Description
compare function

The compare function used for sorting.

Author:

Members

compare :function

The compare function used for sorting.

Default Value:
  • defaultCompare

data :Array.<Object>

The data items of the priority queue.

length :Number

The length of the priority queue.

Default Value:
  • 0

Methods

peek() → {Object}

Returns the item with the highest priority without removal.

Returns:
Object -

The item with the highest priority.

pop() → {Object}

Returns the item with the highest priority and removes it from the priority queue.

Returns:
Object -

The item with the highest priority.

push(item)

Pushes an item to the priority queue.

Parameters:
Name Type Description
item Object

The item to add.