m865.datastructures
Class StackLL.StackLLIterator<T>

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

public class StackLL.StackLLIterator<T>
extends java.lang.Object
implements java.util.Iterator<T>

An iterator for an Linked List stack.


Constructor Summary
protected StackLL.StackLLIterator(StackLL<T> s)
          Constructor for a StackLL 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

StackLL.StackLLIterator

protected StackLL.StackLLIterator(StackLL<T> s)
Constructor for a StackLL 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. Throws an UnsupportedOperationException.

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