Package nl.rrd.wool.utils
Class CurrentIterator<T>
- java.lang.Object
-
- nl.rrd.wool.utils.CurrentIterator<T>
-
- Type Parameters:
T- the type of elements in the iterator
public class CurrentIterator<T> extends Object
This iterator can return the current element rather than the next element as a normal iterator does. At construction it is positioned before the first element. You can move to the first element withmoveNext(). Then you can access the current element as many times as needed withgetCurrent(), and you can move to the next element withmoveNext().
-
-
Constructor Summary
Constructors Constructor Description CurrentIterator(Iterator<? extends T> it)Constructs a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TgetCurrent()Returns the current element.booleanmoveNext()Moves to the next element.booleanremoveMoveNext()Removes the current element and moves to the next element.
-
-
-
Method Detail
-
getCurrent
public T getCurrent()
Returns the current element. If the iterator is positioned before the first element or after the last element, this method returns null. An element itself may also be null. UsemoveNext()to know the position.- Returns:
- the current element (can be null)
-
moveNext
public boolean moveNext()
Moves to the next element. If there is no more element, this method returns false.- Returns:
- true if the iterator is at the next element, false if there is no more element
-
removeMoveNext
public boolean removeMoveNext()
Removes the current element and moves to the next element. If there is no more element, this method returns false.- Returns:
- true if the iterator is at the next element, false if there is no more element
-
-