Class FilterListIterator<E>

java.lang.Object
org.apache.commons.collections4.iterators.FilterListIterator<E>
Type Parameters:
E - The type of elements returned by this iterator.
All Implemented Interfaces:
Iterator<E>, ListIterator<E>

public class FilterListIterator<E> extends Object implements 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 Details

    • iterator

      private ListIterator<? extends E> iterator
      The iterator being used
    • predicate

      private Predicate<? super E> predicate
      The predicate being used
    • nextObject

      private E nextObject
      The value of the next (matching) object, when nextObjectSet is true.
    • nextObjectSet

      private boolean nextObjectSet
      Whether or not the nextObject has been set (possibly to null).
    • previousObject

      private E previousObject
      The value of the previous (matching) object, when previousObjectSet is true.
    • previousObjectSet

      private boolean previousObjectSet
      Whether or not the previousObject has been set (possibly to null).
    • nextIndex

      private int nextIndex
      The index of the element that would be returned by next().
  • Constructor Details

    • FilterListIterator

      public FilterListIterator()
      Constructs a new FilterListIterator that will not function until setListIterator and setPredicate are invoked.
    • FilterListIterator

      public FilterListIterator(ListIterator<? extends E> iterator)
      Constructs a new FilterListIterator that will not function until setPredicate is invoked.
      Parameters:
      iterator - The iterator to use
    • FilterListIterator

      public FilterListIterator(ListIterator<? extends E> iterator, Predicate<? super E> predicate)
      Constructs a new FilterListIterator.
      Parameters:
      iterator - The iterator to use
      predicate - The predicate to use
    • FilterListIterator

      public FilterListIterator(Predicate<? super E> predicate)
      Constructs a new FilterListIterator that will not function until setListIterator is invoked.
      Parameters:
      predicate - The predicate to use.
  • Method Details