laser.util
Class LeftToRightIterator

java.lang.Object
  extended by laser.util.LeftToRightIterator
All Implemented Interfaces:
java.util.Iterator

public class LeftToRightIterator
extends java.lang.Object
implements java.util.Iterator

The LeftToRightIterator class guarentees that the elements within the given Array are iterated in left to right order (ie. starting at index zero and ending at the number of elements minus one).

NOTE: The LeftToRightIterator takes a "snap-shot" of the array when it is created and iterates through the elements contained within the "snap-shot" of the array. This means that the iterator will not take into account any modifications to the underlying array.


Constructor Summary
LeftToRightIterator(java.lang.Object[] a)
          Creates a new LeftToRightIterator for the given array.
 
Method Summary
 boolean hasNext()
          Returns whether or not there are more elements left to be returned.
 java.lang.Object next()
          Returns the next element if it exists.
 void remove()
          Removes the last element returned by the iterator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LeftToRightIterator

public LeftToRightIterator(java.lang.Object[] a)
Creates a new LeftToRightIterator for the given array.

Parameters:
a - The array of interest
Method Detail

hasNext

public boolean hasNext()
Returns whether or not there are more elements left to be returned.

Specified by:
hasNext in interface java.util.Iterator
Returns:
True if there are more elements and false otherwise

next

public java.lang.Object next()
                      throws java.util.NoSuchElementException
Returns the next element if it exists.

Specified by:
next in interface java.util.Iterator
Returns:
The next element
Throws:
java.util.NoSuchElementException - if there are no more elements to be returned

remove

public void remove()
            throws java.lang.UnsupportedOperationException
Removes the last element returned by the iterator.

NOTE: The remove operation is not supported.

Specified by:
remove in interface java.util.Iterator
Throws:
java.lang.UnsupportedOperationException