grokking-algorithms/chapter9/examples/priorityqueuetest.py

13 lines
309 B
Python
Raw Normal View History

2023-12-19 15:47:26 +00:00
from queue import PriorityQueue
customers = (
PriorityQueue()
) # we initialise the PQ class instead of using a function to operate upon a list.
customers.put((2, "Harry"))
customers.put((3, "Charles"))
customers.put((1, "Riya"))
customers.put((4, "Stacy"))
while customers:
print(customers.get())