A function that takes the a value that has previously been inserted, and returns a priority.
A lower score is higher priority.
Ex. (monster) => monster.speed
Insert data into the queue
The data to insert
Get the item with the lowest priotity score, WITHOUT removing it.
Get the item with the lowest priority score, removing it from the queue.
Returns the number of items in the queue.
Generated using TypeDoc
HeapPriorityQueue allows for push/pop based on an attribute of the inserted objects. The heap based implementation underneath has theoretic O(log(n)) insert/pop time and O(c) peek time.
Because the bubble up/down might not preserve order within items of the same priority, the array-priority-queue can be a better though slower choice in some cases.