Skip to content
Advertisement

Can I get an item from a PriorityQueue without removing it yet?

I want to get the next item in queue but I don’t want to dequeue it. Is it possible in Python’s queue.PriorityQueue? From the docs, I don’t see how can it be done

Advertisement

Answer

When you get item form the queue as per theory it will remove from the queue. You have to write your own function which will give you last element of PriorityQueue. You can create a peek function by inherit the priorityqueue.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement