Package org.wildfly.common.array
Class ArrayIterator<E>
java.lang.Object
org.wildfly.common.array.ArrayIterator<E>
- All Implemented Interfaces:
Enumeration<E>,Iterator<E>,ListIterator<E>,EnumerationIterator<E>
public final class ArrayIterator<E>
extends Object
implements ListIterator<E>, EnumerationIterator<E>
A read-only iterator over an array.
- Author:
- David M. Lloyd
-
Constructor Summary
ConstructorsConstructorDescriptionArrayIterator(E[] elements) Construct a new instance.ArrayIterator(E[] elements, boolean descending) Construct a new instance.ArrayIterator(E[] elements, boolean descending, int startIdx) Construct a new instance.ArrayIterator(E[] elements, int startIdx) Construct a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidUnsupported.booleanhasNext()Determine if there are more elements to iterate over in the direction of this iterator.booleanDetermine if there are more elements to iterate over in the reverse direction of this iterator.next()Get the next element in the direction of this iterator.intGet the next index in the direction of this iterator.previous()Get the next element in the reverse direction of this iterator.intGet the next index in the reverse direction of this iterator.voidremove()Unsupported.voidUnsupported.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Enumeration
asIteratorMethods inherited from interface org.wildfly.common.iteration.EnumerationIterator
hasMoreElements, nextElementMethods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
ArrayIterator
Construct a new instance.- Parameters:
elements- the elements to iterate over
-
ArrayIterator
Construct a new instance.- Parameters:
elements- the elements to iterate overdescending-trueto iterate in descending order,falseotherwise
-
ArrayIterator
Construct a new instance.- Parameters:
elements- the elements to iterate overstartIdx- the starting index (must be within the bounds ofelements)
-
ArrayIterator
Construct a new instance.- Parameters:
elements- the elements to iterate overdescending-trueto iterate in descending order,falseotherwisestartIdx- the starting index (must be within the bounds ofelements)
-
-
Method Details
-
hasPrevious
public boolean hasPrevious()Determine if there are more elements to iterate over in the reverse direction of this iterator.- Specified by:
hasPreviousin interfaceListIterator<E>- Returns:
trueif there are more elements,falseotherwise
-
hasNext
public boolean hasNext()Determine if there are more elements to iterate over in the direction of this iterator. -
previous
Get the next element in the reverse direction of this iterator.- Specified by:
previousin interfaceListIterator<E>- Returns:
- the next element
-
next
Get the next element in the direction of this iterator. -
nextIndex
public int nextIndex()Get the next index in the direction of this iterator.- Specified by:
nextIndexin interfaceListIterator<E>- Returns:
- the next index
-
previousIndex
public int previousIndex()Get the next index in the reverse direction of this iterator.- Specified by:
previousIndexin interfaceListIterator<E>- Returns:
- the next index
-
remove
public void remove()Unsupported. -
set
Unsupported.- Specified by:
setin interfaceListIterator<E>- Parameters:
e- ignored
-
add
Unsupported.- Specified by:
addin interfaceListIterator<E>- Parameters:
e- ignored
-