Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 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