Created
May 5, 2013 05:54
-
-
Save st0le/5519890 to your computer and use it in GitHub Desktop.
Using PriorityQueue from Queue Module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random,Queue | |
pq = Queue.PriorityQueue() | |
for q in range(10): | |
p = random.randint(0,100) | |
print "Inserting %d with priority %d" % (q,p) | |
pq.put((p,q)) | |
while not pq.empty(): | |
print pq.get() | |
raw_input() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment