June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -1,18 +1,12 @@
|
|||
import tables
|
||||
import HeapQueue
|
||||
|
||||
var
|
||||
pq = initTable[int, string]()
|
||||
var pq = newHeapQueue[(int, string)]()
|
||||
|
||||
proc main() =
|
||||
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")
|
||||
pq.push((3, "Clear drains"))
|
||||
pq.push((4, "Feed cat"))
|
||||
pq.push((5, "Make tea"))
|
||||
pq.push((1, "Solve RC tasks"))
|
||||
pq.push((2, "Tax return"))
|
||||
|
||||
for i in countUp(1,5):
|
||||
if pq.hasKey(i):
|
||||
echo i, ": ", pq[i]
|
||||
pq.del(i)
|
||||
|
||||
main()
|
||||
while pq.len() > 0:
|
||||
echo pq.pop()
|
||||
|
|
|
|||
18
Task/Priority-queue/Nim/priority-queue-3.nim
Normal file
18
Task/Priority-queue/Nim/priority-queue-3.nim
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import tables
|
||||
|
||||
var
|
||||
pq = initTable[int, string]()
|
||||
|
||||
proc main() =
|
||||
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")
|
||||
|
||||
for i in countUp(1,5):
|
||||
if pq.hasKey(i):
|
||||
echo i, ": ", pq[i]
|
||||
pq.del(i)
|
||||
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue