Created
September 16, 2019 02:55
-
-
Save pn11/aac52d40bcfc24a1b000f121619a3d21 to your computer and use it in GitHub Desktop.
Priority queue
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 heapq as hq | |
que = [] | |
hq.heappush(que, (1, "TEST1")) | |
hq.heappush(que, (0, "TEST0")) | |
hq.heappush(que, (2, "TEST2")) | |
print(que) | |
priority, a = hq.heappop(que) | |
print(priority, a) | |
print(que) | |
priority, a = hq.heappop(que) | |
print(priority, a) | |
print(que) | |
priority, a = hq.heappop(que) | |
print(priority, a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output