E
- is the generic type of the elements to iterate/enumerate.public class ArrayIterator<E> extends Object implements Enumeration<E>, Iterator<E>
Iterator
and Enumeration
to iterate/enumerate a given array. For
performance the array is NOT copied so please note that modifications of the array given at construction will
directly be reflected by this ArrayIterator
.Modifier and Type | Field and Description |
---|---|
private E[] |
array
The array to iterate/enumerate.
|
private int |
index
The current index in
array . |
private int |
stopIndex
The index where iteration stops.
|
Constructor and Description |
---|
ArrayIterator(E[] array)
The constructor.
|
ArrayIterator(E[] array,
int start,
int end)
The constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
hasMoreElements() |
boolean |
hasNext() |
E |
next() |
E |
nextElement() |
void |
remove() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
private final E[] array
private final int stopIndex
private int index
array
.public ArrayIterator(E[] array)
array
- is the array to iterate/enumerate.public ArrayIterator(E[] array, int start, int end)
array
- is the array to iterate/enumerate.start
- is the index of the first item to iterate/enumerate in array
.end
- is the index of the last item to iterate/enumerate in array
.public boolean hasMoreElements()
hasMoreElements
in interface Enumeration<E>
public E nextElement()
nextElement
in interface Enumeration<E>
Copyright © 2001–2016 mmm-Team. All rights reserved.