com.sun.electric.database.text
Class ArrayIterator<E>

java.lang.Object
  extended by com.sun.electric.database.text.ArrayIterator<E>
All Implemented Interfaces:
java.util.Iterator<E>

public class ArrayIterator<E>
extends java.lang.Object
implements java.util.Iterator<E>

An iterator over an array.


Field Summary
static com.sun.electric.database.text.ArrayIterator.EmptyIterator EMPTY_ITERATOR
          The empty iterator (immutable).
 
Method Summary
static
<E> java.util.Iterator<E>
emptyIterator()
          Returns the empty iterator (immutable).
 boolean hasNext()
          Returns true if the iteration has more elements.
static
<E> java.util.Iterator<E>
iterator(E[] array)
          Returns iterator over elements of array.
static
<E> java.util.Iterator<E>
iterator(E[] array, int start, int limit)
          Returns iterator over range [start,limit) of elements of array.
 E next()
          Returns the next element in the iteration.
 void remove()
          Removes from the underlying collection the last element returned by the iterator (unsupported operation).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_ITERATOR

public static final com.sun.electric.database.text.ArrayIterator.EmptyIterator EMPTY_ITERATOR
The empty iterator (immutable).

See Also:
emptyIterator()
Method Detail

iterator

public static <E> java.util.Iterator<E> iterator(E[] array)
Returns iterator over elements of array.

Parameters:
array - array with elements or null.
Returns:
iterator over elements of the array or NULL_ITERATOR.

iterator

public static <E> java.util.Iterator<E> iterator(E[] array,
                                                 int start,
                                                 int limit)
Returns iterator over range [start,limit) of elements of array.

Parameters:
array - array with elements or null.
start - start index of the range.
limit - limit of the range
Returns:
iterator over range of elements of the array or EMPTY_ITERATOR.
Throws:
java.lang.IndexOutOfBoundsException - if start or limit are not correct

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 java.util.Iterator<E>
Returns:
true if the iterator has more elements.

next

public E next()
Returns the next element in the iteration. Calling this method repeatedly until the hasNext() method returns false will return each element in the underlying collection exactly once.

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

remove

public void remove()
Removes from the underlying collection the last element returned by the iterator (unsupported operation).

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

emptyIterator

public static final <E> java.util.Iterator<E> emptyIterator()
Returns the empty iterator (immutable). Unlike the like-named field, this method is parameterized.

This example illustrates the type-safe way to obtain an empty set:

     Iterator<String> s = ArrayIterator.emptyIterator();
 
Implementation note: Implementations of this method need not create a separate Iterator object for each call. Using this method is likely to have comparable cost to using the like-named field. (Unlike this method, the field does not provide type safety.)

See Also:
EMPTY_ITERATOR