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
ArrayPriorityQueue allows for push/pop based on an attribute of the inserted objects. The array based implementation underneath has theoretic O(c) insert time, and O(n) peek/pop time.
Though this is slower in many cases than the heap based implementation, it preserves the order better and can result in more 'normal' paths when used with pathfinding.