Class CollectionsPlume.FilteredIterator<T extends @Nullable Object>

java.lang.Object
org.plumelib.util.CollectionsPlume.FilteredIterator<T>
Type Parameters:
T - the type of elements of the iterator
All Implemented Interfaces:
Iterator<T>
Enclosing class:
CollectionsPlume

public static final class CollectionsPlume.FilteredIterator<T extends @Nullable Object> extends Object implements Iterator<T>
An iterator that only returns elements that match the given Filter.
  • Field Details

    • itor

      Iterator<T extends @Nullable Object> itor
      The iterator that this object is filtering.
    • filter

      Filter<T extends @Nullable Object> filter
      The predicate that determines which elements to retain.
    • invalidT

      T extends @Nullable Object invalidT
      A marker object, distinct from any object that the iterator can return.
    • current

      T extends @Nullable Object current
      The next object that this iterator will yield, or invalidT if currentValid is false.
    • currentValid

      boolean currentValid
      True iff current is an object from the wrapped iterator.
  • Constructor Details

    • FilteredIterator

      public FilteredIterator(Iterator<T> itor, Filter<T> filter)
      Create an iterator that only returns elements of itor that match the given Filter.
      Parameters:
      itor - the Iterator to filter
      filter - the predicate that determines which elements to retain
  • Method Details

    • hasNext

      public boolean hasNext(@GuardSatisfied CollectionsPlume.FilteredIterator<T extends @Nullable Object> this)
      Specified by:
      hasNext in interface Iterator<T extends @Nullable Object>
    • next

      public T next(@GuardSatisfied CollectionsPlume.FilteredIterator<T extends @Nullable Object> this)
      Specified by:
      next in interface Iterator<T extends @Nullable Object>
    • remove

      public void remove(@GuardSatisfied CollectionsPlume.FilteredIterator<T extends @Nullable Object> this)
      Specified by:
      remove in interface Iterator<T extends @Nullable Object>