Last active
December 10, 2015 09:59
-
-
Save jaytaph/4418363 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
pq = PriorityQueue[5:"foo":10, 5:"bar":2, 10:"baz":0, 1:"wuq":0]; | |
foreach (pq as key:value:prio, meta) { | |
if (meta.first) io.print("This is the first item!\n"); | |
if (meta.last) io.print("This is the last item!\n"); | |
io.print("Key: ",key," Val: ",value," Prio: ", prio); | |
} | |
Output: | |
This is the first item! | |
Key: 1 Val: wuq Prio: 0 | |
Key: 5 Val: bar Prio: 2 | |
Key: 5 Val: foo Prio: 10 | |
This is the last item! | |
Key: 10 Val: baz Prio: 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment