Iterator over any array.
The array can be either an array of object or of primitives. If you know
that you have an object array, the
ObjectArrayIterator
class is a better choice, as it will perform better.
The iterator implements a reset method, allowing the reset of
the iterator back to the start if required.
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final Object | array
The array to iterate over |
| pack-priv final int | endIndex
The end index to loop to |
| pack-priv int | index
The current iterator index |
| pack-priv final int | startIndex
The start index to loop from |
| Access | Constructor and Description |
|---|---|
| public | ArrayIterator(final Object
the array to iterate over. array)Constructs an ArrayIterator that will iterate over the values in the specified array. |
| public | ArrayIterator(final Object
the array to iterate over. array, final int the index to start iterating at. startIndex)Constructs an ArrayIterator that will iterate over the values in the specified array from a specific start index. |
| public | ArrayIterator(final Object
the array to iterate over. array, final int the index to start iterating at. startIndex, final int the index to finish iterating at. endIndex)Construct an ArrayIterator that will iterate over a range of values in the specified array. |
| Modifier and Type | Method and Description |
|---|---|
| protected void | checkBound(final int
the index to check bound, final int the length of the array len, final String the index type (for error messages) type)Checks whether the index is valid or not. |
| public Object | Returns: the array this iterator iterates over.Gets the array that this iterator is iterating over. |
| public int | |
| public int | |
| public boolean | Returns: true if there is a next element to returnImplements java. |
| public E | Returns: the next element in the arrayImplements java. |
| public void | |
| public void | reset()
Implements org. |
| array | back to summary |
|---|---|
| pack-priv final Object array The array to iterate over | |
| endIndex | back to summary |
|---|---|
| pack-priv final int endIndex The end index to loop to | |
| index | back to summary |
|---|---|
| pack-priv int index The current iterator index | |
| startIndex | back to summary |
|---|---|
| pack-priv final int startIndex The start index to loop from | |
| ArrayIterator | back to summary |
|---|---|
| public ArrayIterator(final Object array) Constructs an ArrayIterator that will iterate over the values in the specified array.
| |
| ArrayIterator | back to summary |
|---|---|
| public ArrayIterator(final Object array, final int startIndex) Constructs an ArrayIterator that will iterate over the values in the specified array from a specific start index.
| |
| ArrayIterator | back to summary |
|---|---|
| public ArrayIterator(final Object array, final int startIndex, final int endIndex) Construct an ArrayIterator that will iterate over a range of values in the specified array.
| |
| checkBound | back to summary |
|---|---|
| protected void checkBound(final int bound, final int len, final String type) Checks whether the index is valid or not.
| |
| getArray | back to summary |
|---|---|
| public Object getArray() Gets the array that this iterator is iterating over.
| |
| getEndIndex | back to summary |
|---|---|
| public int getEndIndex() Gets the end index to loop to.
| |
| getStartIndex | back to summary |
|---|---|
| public int getStartIndex() Gets the start index to loop from.
| |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Returns true if there are more elements to return from the array.
| |
| next | back to summary |
|---|---|
| public E next() Implements java. Returns the next element in the array.
| |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Throws
| |
| reset | back to summary |
|---|---|
| public void reset() Implements org. Resets the iterator back to the start index.
| |