Abstract Data Types
Linux macOS Windows
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
.
$ dima install adt
' 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