// Originally implemented by Lafore; modifed by Sriram // Pemmaraju on Oct 14th, 2007 // Turned into AVLStack on Dec 4th //////////////////////////////////////////////////////////////// class AVLStack { private int maxSize; // size of stack array private AVLNode[] stackArray; private int top; // top of stack //-------------------------------------------------------------- // This is the constructor that takes as an argument the maximum size // s that it ever needs to be public AVLStack(int s) // constructor { maxSize = s; // set array size stackArray = new AVLNode[maxSize]; // create array top = -1; // no items yet } //-------------------------------------------------------------- public void push(AVLNode j) // put item on top of stack { stackArray[++top] = j; // increment top, insert item } //-------------------------------------------------------------- public AVLNode pop() // take item from top of stack { return stackArray[top--]; // access item, decrement top } //-------------------------------------------------------------- public AVLNode peek() // peek at top of stack { return stackArray[top]; } //-------------------------------------------------------------- public boolean isEmpty() // true if stack is empty { return (top == -1); } //-------------------------------------------------------------- public boolean isFull() // true if stack is full { return (top == maxSize-1); } //-------------------------------------------------------------- } // end class myStack ////////////////////////////////////////////////////////////////