edu.colorado.collections
Class DerivedStack

java.lang.Object
  extended by edu.colorado.collections.LinkedSeq
      extended by edu.colorado.collections.DerivedStack
All Implemented Interfaces:
java.lang.Cloneable

public class DerivedStack
extends LinkedSeq

A DerivedStack is a LinkedSeq that can easily be used as if it were a stack of Objects. The stack's objects are kept in the sequence of the superclass, with the top of the stack at the head of the sequence.

Java Source Code for this class:
Not available because this is a Programming Project for my students.

See Also:
LinkedSeq, ObjectStack, ObjectLinkedStack

Constructor Summary
DerivedStack()
           
 
Method Summary
 boolean isEmpty()
          Determine whether this stack is empty.
 java.lang.Object peek()
          Get the top item of this stack, without removing the item.
 java.lang.Object pop()
          Get the top item, removing it from this stack.
 void push(java.lang.Object element)
          Push a new item onto this stack.
 
Methods inherited from class edu.colorado.collections.LinkedSeq
addAfter, addAll, addBefore, advance, clone, concatentation, getCurrent, isCurrent, removeCurrent, size, start
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DerivedStack

public DerivedStack()
Method Detail

isEmpty

public boolean isEmpty()
Determine whether this stack is empty.

Parameters:
- - none
Returns:
true if this stack is empty; false otherwise.

peek

public java.lang.Object peek()
Get the top item of this stack, without removing the item.

Parameters:
- - none
Precondition:
This stack is not empty.
Returns:
the top item of the stack
Throws:
java.util.EmptyStackException - Indicates that this stack is empty.

pop

public java.lang.Object pop()
Get the top item, removing it from this stack.

Parameters:
- - none
Precondition:
This stack is not empty.
Postcondition:
The return value is the top item of this stack, and the item has been removed.
Throws:
java.util.EmptyStackException - Indicates that this stack is empty.

push

public void push(java.lang.Object element)
Push a new item onto this stack. The new item may be the null reference.

Parameters:
item - the item to be pushed onto this stack
Postcondition:
The item has been pushed onto this stack.
Throws:
java.lang.OutOfMemoryError - Indicates insufficient memory for increasing the stack's capacity.