T
- The type of object to iterate overpublic class ArrayIterator<T>
extends java.lang.Object
implements java.util.Iterator<T>
Iterator
which will go over an Object array. Like most Iterators this
class is NOT thread safe.Modifier and Type | Method and Description |
---|---|
boolean |
hasNext() |
static <T> java.lang.Iterable<T> |
makeIterable(T[] array)
Use as a convience when
Iterable is the desired interface. |
static <T> java.lang.Iterable<T> |
makeIterable(T[] array,
boolean newInstanceOnCall)
Use as a convience when
Iterable is the desired interface. |
static <T> java.util.Iterator<T> |
makeIterator(T[] array)
Construct a new
Iterator that will start at position zero of the provided array. |
T |
next() |
void |
reset()
Reset the iterator back to position
0 . |
public static <T> java.util.Iterator<T> makeIterator(T[] array)
Iterator
that will start at position zero of the provided array.T
- The type of object to iterate overarray
- Array to iterate overIterator
that will go over the provided arraypublic static <T> java.lang.Iterable<T> makeIterable(T[] array)
Iterable
is the desired interface. This is equivalent to
calling makeIterable(Object[], boolean)
with a true
to specify new instances
on iteration.T
- The type of object to iterate overarray
- Array to be iterated overIterable
that will go over the arraypublic static <T> java.lang.Iterable<T> makeIterable(T[] array, boolean newInstanceOnCall)
Iterable
is the desired interface. If the returned
Iterable
wont be invoked concurrently, then this can be called to reuse the
Iterator
instance by simply passing false
for newInstanceOnCall
. If
true
is specified then a new instance will be returned on every invocation, allowing
for the iterator to be created concurrently and not have the state of each iterator be impacted.
If false
is provided then the returned Iterator
will be reset each time.T
- The type of object to iterate overarray
- Array to be iterated overnewInstanceOnCall
- true
to create new instances on each invocation of Iterable.iterator()
Iterable
that will go over the arraypublic boolean hasNext()
hasNext
in interface java.util.Iterator<T>
public void reset()
0
.