!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! This file is an example of how to use the Stack class, by Fredrik Ramsberg.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Include ">stack.h";
! Set up stack 1
Array stack1tab table 3; ! Last argument states max # of items on stack
Stack stack1 "Stack 1"
with
stacktable stack1tab;
! Set up stack 2
Array stack2tab table 10; ! Last argument states max # of items on stack
print "Size of stack 1: ",stack1.size(), "^";
print "Size of stack 2: ",stack2.size(), "^";
print "# of elements on stack 1: ",stack1.element_count(), "^";
print "# of elements on stack 2: ",stack2.element_count(), "^";
print "^";
! Pop all values off stack 1
problem=false;
while(~~problem) {
x=stack1.pop();
if(stack1.status==stack1.success)
print "Popped ", x, " from stack 1^";
else
problem=true;
}
print "^";
! Pop all values off stack 2
problem=false;
while(~~problem) {
x=stack2.pop();
if(stack2.status==stack2.success)
print "Popped ", x, " from stack 2^";
else
problem=true;
}