structure
Class AbstractStack

java.lang.Object
  extended by structure.AbstractStructure
      extended by structure.AbstractLinear
          extended by structure.AbstractStack
All Implemented Interfaces:
Linear, Stack, Structure
Direct Known Subclasses:
StackArray, StackList, StackVector

public abstract class AbstractStack
extends AbstractLinear
implements Stack

An abstract structure describing a Last-In, First-Out structure. Stacks are typically used to store the state of a recursively solved problem.


Constructor Summary
AbstractStack()
           
 
Method Summary
 java.lang.Object getFirst()
          Deprecated. Please use method get, rather than getFirst!
 java.lang.Object peek()
          Fetch a reference to the top element of the stack.
 java.lang.Object pop()
          Remove an element from the top of the stack.
 void push(java.lang.Object item)
          Add an element from the top of the stack.
 
Methods inherited from class structure.AbstractLinear
empty, remove
 
Methods inherited from class structure.AbstractStructure
contains, elements, hashCode, isEmpty, values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface structure.Stack
add, empty, get, remove, size
 
Methods inherited from interface structure.Structure
clear, contains, elements, isEmpty, iterator, remove, values
 

Constructor Detail

AbstractStack

public AbstractStack()
Method Detail

push

public void push(java.lang.Object item)
Add an element from the top of the stack.

Specified by:
push in interface Stack
Parameters:
item - The element to be added to the stack top.
Postcondition:
item is added to stack will be popped next if no intervening add

pop

public java.lang.Object pop()
Remove an element from the top of the stack.

Specified by:
pop in interface Stack
Returns:
The item removed from the top of the stack.
Precondition:
stack is not empty
Postcondition:
most recently added item is removed and returned

getFirst

public java.lang.Object getFirst()
Deprecated. Please use method get, rather than getFirst!

Fetch a reference to the top element of the stack.

Specified by:
getFirst in interface Stack
Returns:
A reference to the top element of the stack.
Precondition:
stack is not empty
Postcondition:
top value (next to be popped) is returned

peek

public java.lang.Object peek()
Fetch a reference to the top element of the stack. Provided for compatibility with java.util.Stack.

Specified by:
peek in interface Stack
Returns:
A reference to the top element of the stack.
Precondition:
stack is not empty
Postcondition:
top value (next to be popped) is returned