Class FilteringIterator<T>

java.lang.Object
org.bzdev.util.FilteringIterator<T>
All Implemented Interfaces:
Iterator<T>

public class FilteringIterator<T> extends Object implements Iterator<T>
Iterator that filters out elements.
  • Constructor Details

    • FilteringIterator

      public FilteringIterator(Iterator<T> it)
      Constructor.
      Parameters:
      it - the iterator to filter
  • Method Details

    • addToFilter

      public void addToFilter(T element)
      Add an element to filter. The iterator will return a sequence of elements. Those elements that match ones added to the filter will be ignored. An element o matches an element e in the filter if either o and e are both null or if o.equals(e) returns true.
      Parameters:
      element - the element to filter
    • addToFilter

      public void addToFilter(Collection<T> elements)
      Add elements to filter. The iterator will return a sequence of elements. Those elements that match ones added to the filter will be ignored. An element o matches an element e in the filter if either o and e are both null or if o.equals(e) returns true.
      Parameters:
      elements - the elements to filter
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<T>
    • next

      public T next() throws NoSuchElementException
      Specified by:
      next in interface Iterator<T>
      Throws:
      NoSuchElementException
    • remove

      Specified by:
      remove in interface Iterator<T>
      Throws:
      UnsupportedOperationException
      IllegalStateException