public class ArrayIntListIterator extends Object implements IntListIterator
int
values.
This class implements ListIterator
allowing
seamless integration with other APIs.
The iterator can be reset to the start if required.
add()
and remove()
are unsupported, but
set()
is supported.
Modifier and Type | Field and Description |
---|---|
protected int[] |
array
The array to iterate over
|
protected int |
cursor
Cursor position
|
protected int |
last
Last returned position
|
Constructor and Description |
---|
ArrayIntListIterator(int[] array)
Constructs an iterator over an array of
int values. |
Modifier and Type | Method and Description |
---|---|
void |
add(int value)
Adds the specified value to the list underlying the iterator at the
current iteration index (optional operation).
|
void |
add(Integer value) |
static ArrayIntListIterator |
copyOf(int[] array)
Creates an iterator over a copy of an array of
int values. |
boolean |
hasNext() |
boolean |
hasPrevious() |
boolean |
isModifiable()
Checks whether the iterator can currently be modified.
|
boolean |
isResettable()
Checks whether the iterator can be reset.
|
Integer |
next() |
int |
nextIndex() |
int |
nextInt()
Gets the next value from the iterator
|
Integer |
previous() |
int |
previousIndex() |
int |
previousInt()
Gets the previous value from the iterator.
|
void |
remove() |
void |
reset()
Resets the iterator back to its initial state (optional operation).
|
void |
set(int value)
Sets the last retrieved value from the iterator (optional operation).
|
void |
set(Integer value) |
protected final int[] array
protected int cursor
protected int last
public ArrayIntListIterator(int[] array)
int
values.
The array is assigned internally, thus the caller holds a reference to the internal state of the returned iterator. It is not recommended to modify the state of the array after construction.
array
- the array to iterate over, must not be nullIllegalArgumentException
- if the array is nullpublic static ArrayIntListIterator copyOf(int[] array)
int
values.
The specified array is copied, ensuring the original data is unaltered.
Note that the class is not immutable due to the set
methods.
array
- the array to iterate over, must not be nullIllegalArgumentException
- if the array is nullpublic boolean isModifiable()
PrimitiveIterator
isModifiable
in interface PrimitiveIterator<Integer>
true
if the modification methods of the iterator can be usedpublic boolean isResettable()
PrimitiveIterator
isResettable
in interface PrimitiveIterator<Integer>
true
if the object can be resetpublic boolean hasNext()
public int nextIndex()
nextIndex
in interface ListIterator<Integer>
public int nextInt()
IntIterator
nextInt
in interface IntIterator
public boolean hasPrevious()
hasPrevious
in interface ListIterator<Integer>
public int previousIndex()
previousIndex
in interface ListIterator<Integer>
public int previousInt()
IntListIterator
previousInt
in interface IntListIterator
public Integer previous()
previous
in interface ListIterator<Integer>
public void add(int value)
IntListIterator
add
in interface IntListIterator
value
- the value to addpublic void add(Integer value)
add
in interface ListIterator<Integer>
public void remove()
public void set(int value)
IntListIterator
set
in interface IntListIterator
value
- the value to setpublic void set(Integer value)
set
in interface ListIterator<Integer>
public void reset()
PrimitiveIterator
reset
in interface PrimitiveIterator<Integer>
Copyright © 2005-2012 Joda.org. All Rights Reserved.