Time for an 2014 update…
This commit is contained in:
parent
372c577f83
commit
09687c4926
2520 changed files with 34227 additions and 7318 deletions
18
Task/Priority-queue/Groovy/priority-queue.groovy
Normal file
18
Task/Priority-queue/Groovy/priority-queue.groovy
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import groovy.transform.Canonical
|
||||
|
||||
@Canonical
|
||||
class Task implements Comparable<Task> {
|
||||
int priority
|
||||
String name
|
||||
int compareTo(Task o) { priority <=> o?.priority }
|
||||
}
|
||||
|
||||
new PriorityQueue<Task>().with {
|
||||
add new Task(priority: 3, name: 'Clear drains')
|
||||
add new Task(priority: 4, name: 'Feed cat')
|
||||
add new Task(priority: 5, name: 'Make tea')
|
||||
add new Task(priority: 1, name: 'Solve RC tasks')
|
||||
add new Task(priority: 2, name: 'Tax return')
|
||||
|
||||
while (!empty) { println remove() }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue