Skip to content

Instantly share code, notes, and snippets.

@jaytaph
Last active December 10, 2015 09:59
Show Gist options
  • Save jaytaph/4418363 to your computer and use it in GitHub Desktop.
Save jaytaph/4418363 to your computer and use it in GitHub Desktop.
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