org.elkoserver.util
Class ArrayIterator<V>

java.lang.Object
  extended by org.elkoserver.util.ArrayIterator<V>
All Implemented Interfaces:
Iterator<V>

public class ArrayIterator<V>
extends Object
implements Iterator<V>

Iterator over an array of objects. Usable in iterator-based for loops when the underlying array is null, and when you actually need an explicit iterator.


Constructor Summary
ArrayIterator(V[] array)
          Constructor.
 
Method Summary
 boolean hasNext()
          Returns true if the iteration has more elements.
 V next()
          Returns the next element in the iteration.
 void remove()
          This operation is not supported.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayIterator

public ArrayIterator(V[] array)
Constructor.

Parameters:
array - The array to iterate over.
Method Detail

hasNext

public boolean hasNext()
Returns true if the iteration has more elements. (In other words, returns true if next() would return an element rather than throwing an exception.)

Specified by:
hasNext in interface Iterator<V>
Returns:
true if the iterator has more elements.

next

public V next()
Returns the next element in the iteration.

Specified by:
next in interface Iterator<V>
Returns:
the next element in the iteration.
Throws:
NoSuchElementException - iteration has no more elements.

remove

public void remove()
This operation is not supported.

Specified by:
remove in interface Iterator<V>
Throws:
UnsupportedOperationException - always.