Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
37
Task/Queue-Definition/VBScript/queue-definition.vb
Normal file
37
Task/Queue-Definition/VBScript/queue-definition.vb
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
' Queue Definition - VBScript
|
||||
Option Explicit
|
||||
Dim queue, i, x
|
||||
Set queue = CreateObject("System.Collections.ArrayList")
|
||||
If Not empty_(queue) Then Wscript.Echo queue.Count
|
||||
push queue, "Banana"
|
||||
push queue, "Apple"
|
||||
push queue, "Pear"
|
||||
push queue, "Strawberry"
|
||||
Wscript.Echo "Count=" & queue.Count
|
||||
Wscript.Echo pull(queue) & " - Count=" & queue.Count '
|
||||
Wscript.Echo "Head=" & queue.Item(0)
|
||||
Wscript.Echo "Tail=" & queue.Item(queue.Count-1)
|
||||
Wscript.Echo queue.IndexOf("Pear", 0)
|
||||
For i=1 To queue.Count
|
||||
Wscript.Echo join(queue.ToArray(), ", ")
|
||||
x = pull(queue)
|
||||
Next 'i
|
||||
|
||||
Sub push(q, what)
|
||||
q.Add what
|
||||
End Sub 'push
|
||||
|
||||
Function pull(q)
|
||||
Dim what
|
||||
If q.Count > 0 Then
|
||||
what = q(0)
|
||||
q.RemoveAt 0
|
||||
Else
|
||||
what = ""
|
||||
End If
|
||||
pull = what
|
||||
End Function 'pull
|
||||
|
||||
Function empty_(q)
|
||||
empty_ = q.Count = 0
|
||||
End Function 'empty_
|
||||
Loading…
Add table
Add a link
Reference in a new issue