queue
Class MyQueueIterator<E>

java.lang.Object
  extended by queue.MyQueueIterator<E>
All Implemented Interfaces:
Iterator<E>

public class MyQueueIterator<E>
extends Object
implements Iterator<E>

The MyQueueIterator class is an iterator for the array-based MyQueue class. See the javadocs java.util.Iterator for more details.


Constructor Summary
MyQueueIterator()
          Sets up and initializes the Iterator.
 
Method Summary
 boolean hasNext()
          This method runs in O(1) time.
 E next()
          Returns the next element to view in the snapshot of the queue.
 E object()
          Returns the object that was returned by the last call to nextObject().
 void remove()
          This is an optional operation from the java.util.Iterator interface.
 void reset()
          Puts the iterator back in its initial state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MyQueueIterator

public MyQueueIterator()
Sets up and initializes the Iterator. Note: if you need to you should feel free to modify the constructor's signature. (i.e. you can make it take parameters if you'd like).

Method Detail

hasNext

public boolean hasNext()
This method runs in O(1) time.

Specified by:
hasNext in interface Iterator<E>
Returns:
boolean true if more elements exist; false otherwise

next

public E next()
       throws NoSuchElementException
Returns the next element to view in the snapshot of the queue. This method runs in O(1) time.

Specified by:
next in interface Iterator<E>
Returns:
next object to consider
Throws:
NoSuchElementException - if iterator has moved past the last object

object

public E object()
         throws NoSuchElementException
Returns the object that was returned by the last call to nextObject(). Repeated calls to this method return the same object without moving the iterator. This method runs in O(1) time.

Returns:
the object returned by the most recent next()
Throws:
NoSuchElementException - when the iterator is in its initial, before-the-first-object state

reset

public void reset()
Puts the iterator back in its initial state. This method runs in O(1) time.


remove

public void remove()
            throws UnsupportedOperationException
This is an optional operation from the java.util.Iterator interface. We are not implementing this method. You should not be calling or modifying this method.

Specified by:
remove in interface Iterator<E>
Throws:
UnsupportedOperationException