grokking-algorithms/chapter9/examples/priorityqueuetest.py

13 lines
309 B
Python

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())