Priority queue: Difference between revisions

Frink
(Frink)
Line 3,488:
</pre>
 
=={{header|Frink}}==
This uses Frink's ability to call arbitrary Java code and uses Java's PriorityQueue implementation, defining our own comparator function.
<syntaxhighlight lang="frink">pq = newJava["java.util.PriorityQueue", new Comparator[byColumn[0]]]
 
pq.add[[3, "Clear Drains"]]
pq.add[[4, "Feed cat"]]
pq.add[[5, "Make tea"]]
pq.add[[1, "Solve RC tasks"]]
pq.add[[2, "Tax return"]]
 
while ! pq.isEmpty[]
println[pq.poll[]]</syntaxhighlight>
{{out}}
<pre>
[1, Solve RC tasks]
[2, Tax return]
[3, Clear Drains]
[4, Feed cat]
[5, Make tea]
</pre>
 
=={{header|FunL}}==
494

edits