Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
36
Task/Queue-Usage/PureBasic/queue-usage.basic
Normal file
36
Task/Queue-Usage/PureBasic/queue-usage.basic
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
NewList MyStack()
|
||||
|
||||
Procedure Push(n)
|
||||
Shared MyStack()
|
||||
LastElement(MyStack())
|
||||
AddElement(MyStack())
|
||||
MyStack()=n
|
||||
EndProcedure
|
||||
|
||||
Procedure Pop()
|
||||
Shared MyStack()
|
||||
Protected n
|
||||
If FirstElement(MyStack()) ; e.g. Stack not empty
|
||||
n=MyStack()
|
||||
DeleteElement(MyStack(),1)
|
||||
EndIf
|
||||
ProcedureReturn n
|
||||
EndProcedure
|
||||
|
||||
Procedure Empty()
|
||||
Shared MyStack()
|
||||
If ListSize(MyStack())=0
|
||||
ProcedureReturn #True
|
||||
EndIf
|
||||
ProcedureReturn #False
|
||||
EndProcedure
|
||||
|
||||
;---- Example of implementation ----
|
||||
Push(3)
|
||||
Push(1)
|
||||
Push(4)
|
||||
Push(1)
|
||||
Push(5)
|
||||
While Not Empty()
|
||||
Debug Pop()
|
||||
Wend
|
||||
Loading…
Add table
Add a link
Reference in a new issue