Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
40
Task/Priority-queue/SenseTalk/priority-queue.sensetalk
Normal file
40
Task/Priority-queue/SenseTalk/priority-queue.sensetalk
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// PriorityQueue.script
|
||||
set Tasks to a new PriorityQueue
|
||||
|
||||
tell Tasks to add 3,"Clear drains"
|
||||
tell Tasks to add 4,"Feed cat"
|
||||
tell Tasks to add 5,"Make tea"
|
||||
tell Tasks to add 1,"Solve RC tasks"
|
||||
tell Tasks to add 2,"Tax return"
|
||||
|
||||
put "Initial tasks:"
|
||||
put Tasks.report & return
|
||||
|
||||
put Tasks.getTop into topItem
|
||||
put "Top priority: " & topItem & return
|
||||
|
||||
put "Remaining:" & return & Tasks.report
|
||||
|
||||
------
|
||||
properties
|
||||
queue:[]
|
||||
end properties
|
||||
|
||||
to add newPriority, newTask
|
||||
repeat with each item of my queue
|
||||
if newPriority comes before the priority of it then
|
||||
insert {priority:newPriority, task:newTask} before item the counter of my queue
|
||||
return
|
||||
end if
|
||||
end repeat
|
||||
insert {priority:newPriority, task:newTask} into my queue -- add at end if last priority
|
||||
end add
|
||||
|
||||
to getTop
|
||||
pull my queue into firstItem
|
||||
return firstItem
|
||||
end getTop
|
||||
|
||||
to report
|
||||
return (priority of each && task of each for each item of my queue) joined by return
|
||||
end report
|
||||
Loading…
Add table
Add a link
Reference in a new issue