Does a PriorityQueue allow elements already within the queue to be reordered?

后端 未结 3 1978
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-25 19:42

I want to augment or lower the priority of items in a PriorityQueue: for example, I might be downloading a long list of images and suddenly want the thirtieth one t

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-25 19:58

    If you iterate over a priority queue, you will find it is in no particular order (except the first element) If you want to change the order, I suggest you create another priority queue.

    If you wan to change the position of one entry, I suggest you remove it, change its fields as required and add it again.

提交回复
热议问题