Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 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