Top Description Fields Constructors Methods
org.apache.commons.collections4.iterators

public Class ObjectArrayIterator<E>

extends Object
implements ResettableIterator<E>
Class Inheritance
All Implemented Interfaces
org.apache.commons.collections4.ResettableIterator, java.util.Iterator
Known Direct Subclasses
org.apache.commons.collections4.iterators.ObjectArrayListIterator
Type Parameters
<E>
the type of elements returned by this iterator
Imports
java.util.NoSuchElementException, org.apache.commons.collections4.ResettableIterator

An Iterator over an array of objects.

This iterator does not support remove, as the object array cannot be structurally modified.

The iterator implements a reset method, allowing the reset of the iterator back to the start if required.

Since
3.0

Field Summary

Modifier and TypeField and Description
pack-priv final E[]
array

The array

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

Constructor Summary

AccessConstructor and Description
public
ObjectArrayIterator(final E...
the array to iterate over
array
)

Constructs an ObjectArrayIterator that will iterate over the values in the specified array.

public
ObjectArrayIterator(final E[]
the array to iterate over
array
,
final int
the index to start iterating at
start
)

Constructs an ObjectArrayIterator that will iterate over the values in the specified array from a specific start index.

public
ObjectArrayIterator(final E[]
the array to iterate over
array
,
final int
the index to start iterating at
start
,
final int
the index (exclusive) to finish iterating at
end
)

Construct an ObjectArrayIterator that will iterate over a range of values in the specified array.

Method Summary

Modifier and TypeMethod and Description
public E[]

Returns:

the array this iterator iterates over
getArray
()

Gets the array that this iterator is iterating over.

public int

Returns:

the end index
getEndIndex
()

Gets the end index to loop to.

public int

Returns:

the start index
getStartIndex
()

Gets the start index to loop from.

public boolean

Returns:

true if there is a next element to return
hasNext
()

Implements java.util.Iterator.hasNext.

Returns true if there are more elements to return from the array.
public E

Returns:

the next element in the array
next
()

Implements java.util.Iterator.next.

Returns the next element in the array.
public void
public void
reset()

Implements org.apache.commons.collections4.ResettableIterator.reset.

Resets the iterator back to the start index.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

arrayback to summary
pack-priv final E[] array

The array

endIndexback to summary
pack-priv final int endIndex

The end index to loop to

indexback to summary
pack-priv int index

The current iterator index

startIndexback to summary
pack-priv final int startIndex

The start index to loop from

Constructor Detail

ObjectArrayIteratorback to summary
public ObjectArrayIterator(final E... array)

Constructs an ObjectArrayIterator that will iterate over the values in the specified array.

Parameters
array:E[]

the array to iterate over

Exceptions
NullPointerException:
if array is null
ObjectArrayIteratorback to summary
public ObjectArrayIterator(final E[] array, final int start)

Constructs an ObjectArrayIterator that will iterate over the values in the specified array from a specific start index.

Parameters
array:E[]

the array to iterate over

start:int

the index to start iterating at

Exceptions
NullPointerException:
if array is null
IndexOutOfBoundsException:
if the start index is out of bounds
ObjectArrayIteratorback to summary
public ObjectArrayIterator(final E[] array, final int start, final int end)

Construct an ObjectArrayIterator that will iterate over a range of values in the specified array.

Parameters
array:E[]

the array to iterate over

start:int

the index to start iterating at

end:int

the index (exclusive) to finish iterating at

Exceptions
IndexOutOfBoundsException:
if the start or end index is out of bounds
IllegalArgumentException:
if end index is before the start
NullPointerException:
if array is null

Method Detail

getArrayback to summary
public E[] getArray()

Gets the array that this iterator is iterating over.

Returns:E[]

the array this iterator iterates over

getEndIndexback to summary
public int getEndIndex()

Gets the end index to loop to.

Returns:int

the end index

getStartIndexback to summary
public int getStartIndex()

Gets the start index to loop from.

Returns:int

the start index

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Returns true if there are more elements to return from the array.

Returns:boolean

true if there is a next element to return

Annotations
@Override
nextback to summary
public E next()

Implements java.util.Iterator.next.

Returns the next element in the array.

Returns:E

the next element in the array

Annotations
@Override
Exceptions
NoSuchElementException:
if all the elements in the array have already been returned
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Throws UnsupportedOperationException.

Annotations
@Override
Exceptions
UnsupportedOperationException:
always
resetback to summary
public void reset()

Implements org.apache.commons.collections4.ResettableIterator.reset.

Resets the iterator back to the start index.

Annotations
@Override