'''
A priority queue is common use for a heap, and it presents several implementation challenges:
http://www.bogotobogo.com/python/python_PriorityQueue_heapq_Data_Structure.php
'''


# Simplest

try:
    import Queue as Q  # ver. < 3.0
except ImportError:
    import queue as Q

q = Q.PriorityQueue()
q.put(10)
q.put(1)
q.put(5)
while not q.empty():
    print q.get(),

'''
1 5 10
'''

'''
Note that depending on the Python versions, the name of the priority queue is different.
So, we used try and except pair so that we can adjust our container to the version.
'''

#Sample B - tuple

try:
    import Queue as Q  # ver. < 3.0
except ImportError:
    import queue as Q

q = Q.PriorityQueue()
q.put((10,'ten'))
q.put((1,'one'))
q.put((5,'five'))
while not q.empty():
    print q.get(),


'''
(1, 'one') (5, 'five') (10, 'ten')
'''

