adt
Abstract Data Types (ADT) module. This module currently provides Queue and Stack. You can individually import Queue or Stack by using import statement: import adt/queue or import adt/stack.
There are no constants.
There are no functions.
queue — Provides Queue data type
construct() — The constructor. Create an instance of class queue getsize() — Get the size of the Queue isempty() — Check whether the size of the Queue is empty or not makeempty() — Make the Queue empty pop() — Retrieve and remove the head of the Queue, or return nothing if the Queue is empty push() — Insert a new element into the Queue toarray() — Create an array containing all of the elements in the Queue stack — Provides Stack data type
construct() — The constructor. Create an instance of class stack getsize() — Get the size of the Stack isempty() — Check whether the size of the Stack is empty or not makeempty() — Make the Stack empty pop() — Retrieve and remove the top of the Stack, or return nothing if the Stack is empty push() — Push a new element into the top of the Stack toarray() — Create an array containing all of the elements in the Stack
' Queue example
import adt/queue
queue = queue()
queue.push(10)
queue.push(12)
queue.push(8)
while !queue.isempty()
writeln(queue.pop())
endwhile
' Output:
' 10
' 12
' 8
' Stack example
import adt/stack
stack = stack()
stack.push(10)
stack.push(12)
stack.push(8)
while !stack.isempty()
writeln(stack.pop())
endwhile
' Output:
' 8
' 12
' 10
' Queue and Stack example
import adt
queue = queue()
stack = stack()
queue.push(10)
queue.push(12)
queue.push(8)
stack.push(10)
stack.push(12)
stack.push(8)
while !queue.isempty()
writeln(queue.pop())
endwhile
while !stack.isempty()
writeln(stack.pop())
endwhile