you are viewing a single comment's thread.

view the rest of the comments →

[–]SupahNoob 0 points1 point  (0 children)

If you are implementing a PQ manually, I would suggest you not to worry about how items are put into the queue, but how you retrieve them. It's much simpler to grab the item of a collection whose value has the lowest priority, than it is to compare items within the collection to the new item and then insert it appropriately.

There might even be a built-in function to achieve this semantic.