How to get the key with the maximum priority in a priority queue using Julia

I checked the following link and did not find any related information. I guess one can use some trick with Base.Order.ForwardOrdering to accomplish this. Could anyone please let me know about your opinion of this?

dequeue! or dequeue_pair!

Or peek?

1 Like

Thank you for your reply. However, if I understand it correctly, dequeue! will remove and return the key priority pair with the smallest priority from the priority queue.

Ah, so you have a priority queue ordered by smallest value, but you want to extract the largest value?
Then you will have to do a complete search. Or maintain two priority queues that somehow point to the same data, ordered

by smallest and largest value?


thank you. I have already found a way to get around this. :wink:

Maybe you could share with us how you solved the problem?

1 Like

I did not solve it directly and explicitly. If so, I would post the solution already. It’s more like a “get around” and a design thing. I would guess, that if the priorities are numbers, then add a negative sign to all the priorities and then create another priority queue would solve this.

You can specify the sorting method when defining the priority queue.