(I didn't find similar questions, please help combine this question if you find one)
The queue class doesn't have a peek() method. (Offical document link: https://docs.python.org/3/library/queue.html?highlight=queue#queue.PriorityQueue) I'm just curious how can I implement a peek() if I use it like this:
import queue
myqueue = queue.Queue()
myqueue.put(1)
myqueue.peek() #it doesn't have peek() method
I'm also curious that isn't peek() a "standard" operation for queue data structure? Why Python official queue class doesn't provide it?
Thank you very much ~
source https://stackoverflow.com/questions/72005326/how-to-implement-queue-queue-peek
Comments
Post a Comment