Class FilterListIterator<E>
java.lang.Object
org.apache.commons.collections4.iterators.FilterListIterator<E>
- All Implemented Interfaces:
Iterator<E>, ListIterator<E>
Decorates another
ListIterator using a predicate to filter elements.
This iterator decorates the underlying iterator, only allowing through
those elements that match the specified Predicate.
- Since:
- 2.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ListIterator<? extends E> The iterator being usedprivate intThe index of the element that would be returned bynext().private EThe value of the next (matching) object, whennextObjectSetis true.private booleanWhether or not thenextObjecthas been set (possibly tonull).The predicate being usedprivate EThe value of the previous (matching) object, whenpreviousObjectSetis true.private booleanWhether or not thepreviousObjecthas been set (possibly tonull). -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newFilterListIteratorthat will not function untilsetListIteratorandsetPredicateare invoked.FilterListIterator(ListIterator<? extends E> iterator) Constructs a newFilterListIteratorthat will not function untilsetPredicateis invoked.FilterListIterator(ListIterator<? extends E> iterator, Predicate<? super E> predicate) Constructs a newFilterListIterator.FilterListIterator(Predicate<? super E> predicate) Constructs a newFilterListIteratorthat will not function untilsetListIteratoris invoked. -
Method Summary
Modifier and TypeMethodDescriptionvoidNot supported.private voidprivate voidListIterator<? extends E> Gets the iterator this iterator is using.Gets the predicate this iterator is using.booleanhasNext()booleannext()intprevious()intvoidremove()Not supported.voidNot supported.voidsetListIterator(ListIterator<? extends E> iterator) Sets the iterator for this iterator to use.private booleanvoidsetPredicate(Predicate<? super E> predicate) Sets the predicate this the iterator to use.private booleanMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Iterator
forEachRemaining
-
Field Details
-
iterator
The iterator being used -
predicate
-
nextObject
The value of the next (matching) object, whennextObjectSetis true. -
nextObjectSet
private boolean nextObjectSetWhether or not thenextObjecthas been set (possibly tonull). -
previousObject
The value of the previous (matching) object, whenpreviousObjectSetis true. -
previousObjectSet
private boolean previousObjectSetWhether or not thepreviousObjecthas been set (possibly tonull). -
nextIndex
private int nextIndexThe index of the element that would be returned bynext().
-
-
Constructor Details
-
FilterListIterator
public FilterListIterator()Constructs a newFilterListIteratorthat will not function untilsetListIteratorandsetPredicateare invoked. -
FilterListIterator
Constructs a newFilterListIteratorthat will not function untilsetPredicateis invoked.- Parameters:
iterator- the iterator to use
-
FilterListIterator
Constructs a newFilterListIterator.- Parameters:
iterator- the iterator to usepredicate- the predicate to use
-
FilterListIterator
Constructs a newFilterListIteratorthat will not function untilsetListIteratoris invoked.- Parameters:
predicate- the predicate to use.
-
-
Method Details
-
add
Not supported.- Specified by:
addin interfaceListIterator<E>- Parameters:
o- the element to insert
-
hasNext
-
hasPrevious
public boolean hasPrevious()- Specified by:
hasPreviousin interfaceListIterator<E>
-
next
-
nextIndex
public int nextIndex()- Specified by:
nextIndexin interfaceListIterator<E>
-
previous
- Specified by:
previousin interfaceListIterator<E>
-
previousIndex
public int previousIndex()- Specified by:
previousIndexin interfaceListIterator<E>
-
remove
-
set
Not supported.- Specified by:
setin interfaceListIterator<E>- Parameters:
o- the element with which to replace the last element returned bynextorprevious
-
getListIterator
Gets the iterator this iterator is using.- Returns:
- the iterator.
-
setListIterator
Sets the iterator for this iterator to use. If iteration has started, this effectively resets the iterator.- Parameters:
iterator- the iterator to use
-
getPredicate
-
setPredicate
-
clearNextObject
private void clearNextObject() -
setNextObject
private boolean setNextObject() -
clearPreviousObject
private void clearPreviousObject() -
setPreviousObject
private boolean setPreviousObject()
-