m865.datastructures
Class StackAL.StackALIterator<T>

java.lang.Object
  extended by m865.datastructures.StackAL.StackALIterator<T>
All Implemented Interfaces:
java.util.Iterator<T>
Enclosing class:
StackAL<T>

protected class StackAL.StackALIterator<T>
extends java.lang.Object
implements java.util.Iterator<T>

An iterator for an ArrayList stack.


Constructor Summary
protected StackAL.StackALIterator(StackAL<T> s)
          Constructor for an StackAL iterator
 
Method Summary
 boolean hasNext()
          Determines if there is an object in stack that can be returned by next().
 T next()
          Returns the next object in stack, if there is one.
 void remove()
          This method is an optional method of the Iterator interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StackAL.StackALIterator

protected StackAL.StackALIterator(StackAL<T> s)
Constructor for an StackAL iterator

Parameters:
s - the stack for this iterator.
Method Detail

hasNext

public boolean hasNext()
Determines if there is an object in stack that can be returned by next().

Specified by:
hasNext in interface java.util.Iterator<T>
Returns:
true - if there is an object in the stack that can be returned by next().

next

public T next()
Returns the next object in stack, if there is one. It throws a ConcurrentModificationException if the stack has been changed during the iteration.

Specified by:
next in interface java.util.Iterator<T>
Returns:
the next object in the stack.

remove

public void remove()
This method is an optional method of the Iterator interface. If implemented, it would remove from the stack the last element returned by the iterator. Since this would violate the integrity of the abstract stack data structure it is not implemented. If invoked this method throws an UnsupportedOperationException

Specified by:
remove in interface java.util.Iterator<T>