DataStructures
Class StackLi

java.lang.Object
  |
  +--DataStructures.StackLi

public class StackLi
extends java.lang.Object

List-based implementation of the stack.


Constructor Summary
StackLi()
          Construct the stack.
 
Method Summary
 boolean isEmpty()
          Test if the stack is logically empty.
 boolean isFull()
          Test if the stack is logically full.
static void main(java.lang.String[] args)
           
 void makeEmpty()
          Make the stack logically empty.
 void pop()
          Remove the most recently inserted item from the stack.
 void push(java.lang.Object x)
          Insert a new item into the stack.
 java.lang.Object top()
          Get the most recently inserted item in the stack.
 java.lang.Object topAndPop()
          Return and remove the most recently inserted item from the stack.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StackLi

public StackLi()
Construct the stack.
Method Detail

isFull

public boolean isFull()
Test if the stack is logically full.
Returns:
false always, in this implementation.

isEmpty

public boolean isEmpty()
Test if the stack is logically empty.
Returns:
true if empty, false otherwise.

makeEmpty

public void makeEmpty()
Make the stack logically empty.

top

public java.lang.Object top()
Get the most recently inserted item in the stack. Does not alter the stack.
Returns:
the most recently inserted item in the stack, or null, if empty.

pop

public void pop()
         throws Underflow
Remove the most recently inserted item from the stack.
Throws:
Underflow - if the stack is empty.

topAndPop

public java.lang.Object topAndPop()
Return and remove the most recently inserted item from the stack.
Returns:
the most recently inserted item in the stack, or null, if empty.

push

public void push(java.lang.Object x)
Insert a new item into the stack.
Parameters:
x - the item to insert.

main

public static void main(java.lang.String[] args)