posted 15 years ago
Is it acceptable to modify the keys of PriorityQueue elements while they are in the queue? That is, can I do something like this:
I expect to get 2, 0, 4, 3, 1 when I run this, but I actually get 0, 2, 4, 3, 1. This leads me to believe that elements only get sorted when they are inserted into the queue, and not when they're polled. Am I right? If so, is there some other structure I should be using instead for this? To the best of my knowledge, Priority Queues should allow for this...