Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
45
Task/Priority-queue/Run-BASIC/priority-queue.basic
Normal file
45
Task/Priority-queue/Run-BASIC/priority-queue.basic
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
sqliteconnect #mem, ":memory:"
|
||||
#mem execute("CREATE TABLE queue (priority float,descr text)")
|
||||
|
||||
' --------------------------------------------------------------
|
||||
' Insert items into the que
|
||||
' --------------------------------------------------------------
|
||||
#mem execute("INSERT INTO queue VALUES (3,'Clear drains')")
|
||||
#mem execute("INSERT INTO queue VALUES (4,'Feed cat')")
|
||||
#mem execute("INSERT INTO queue VALUES (5,'Make tea')")
|
||||
#mem execute("INSERT INTO queue VALUES (1,'Solve RC tasks')")
|
||||
#mem execute("INSERT INTO queue VALUES (2,'Tax return')")
|
||||
|
||||
'--------------- insert priority between 4 and 5 -----------------
|
||||
#mem execute("INSERT INTO queue VALUES (4.5,'My Special Project')")
|
||||
|
||||
what$ = " -------------- Find first priority ---------------------"
|
||||
mem$ = "SELECT * FROM queue ORDER BY priority LIMIT 1"
|
||||
gosub [getQueue]
|
||||
|
||||
what$ = " -------------- Find last priority ---------------------"
|
||||
mem$ = "SELECT * FROM queue ORDER BY priority desc LIMIT 1"
|
||||
gosub [getQueue]
|
||||
|
||||
what$ = " -------------- Delete Highest Priority ---------------------"
|
||||
mem$ = "DELETE FROM queue WHERE priority = (select max(q.priority) FROM queue as q)"
|
||||
#mem execute(mem$)
|
||||
|
||||
what$ = " -------------- List Priority Sequence ---------------------"
|
||||
mem$ = "SELECT * FROM queue ORDER BY priority"
|
||||
gosub [getQueue]
|
||||
end
|
||||
|
||||
|
||||
[getQueue]
|
||||
print what$
|
||||
#mem execute(mem$)
|
||||
rows = #mem ROWCOUNT()
|
||||
print "Priority Description"
|
||||
for i = 1 to rows
|
||||
#row = #mem #nextrow()
|
||||
priority = #row priority()
|
||||
descr$ = #row descr$()
|
||||
print priority;" ";descr$
|
||||
next i
|
||||
RETURN
|
||||
Loading…
Add table
Add a link
Reference in a new issue