com.neeve.lang
Class XArrayIterator<T>

java.lang.Object
  extended by com.neeve.lang.XArrayIterator<T>
All Implemented Interfaces:
XIterator<T>, Iterator<T>
Direct Known Subclasses:
XDateArrayIterator, XStringArrayIterator

public class XArrayIterator<T>
extends Object
implements XIterator<T>

An XIterator that iterates over an array.


Constructor Summary
XArrayIterator(T[] array)
          Constructs a new array iterator.
XArrayIterator(T[] array, int offset, int length)
          Constructs a new array iterator.
 
Method Summary
 T[] array()
          The array backing this iterator.
 boolean hasNext()
           
 int length()
          Gets the length of the iterator (the number of elements it returns starting with the offset).
 T next()
           
 int offset()
          Gets the offset into the backing array at which this iterator starts.
 void remove()
          Remove is not supported for array iterators.
 XArrayIterator<T> toFirst()
          Resets the iterator to the first element.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XArrayIterator

public XArrayIterator(T[] array)
Constructs a new array iterator.

Parameters:
array - The array to iterate.

XArrayIterator

public XArrayIterator(T[] array,
                      int offset,
                      int length)
Constructs a new array iterator.

Parameters:
array - The backing array.
offset - The offset into the array.
length - The length the number of elements including the offset to iterate.
Method Detail

array

public final T[] array()
The array backing this iterator.

Returns:
The array backing the iterator.

offset

public final int offset()
Gets the offset into the backing array at which this iterator starts.

Returns:
The backing array offset.

length

public final int length()
Gets the length of the iterator (the number of elements it returns starting with the offset).

Returns:
The length of elements returned from the iterator's offset.

hasNext

public final boolean hasNext()
Specified by:
hasNext in interface Iterator<T>

next

public final T next()
Specified by:
next in interface Iterator<T>

remove

public final void remove()
Remove is not supported for array iterators.

Specified by:
remove in interface Iterator<T>
Throws:
UnsupportedOperationException - If called.

toFirst

public final XArrayIterator<T> toFirst()
Description copied from interface: XIterator
Resets the iterator to the first element.

Specified by:
toFirst in interface XIterator<T>


Copyright © 2016 Neeve Research, LLC. All Rights Reserved.