Class ConsumingIterator<E>

java.lang.Object
ch.njol.util.coll.iterator.ConsumingIterator<E>
All Implemented Interfaces:
Iterator<E>

public class ConsumingIterator<E> extends Object implements Iterator<E>
An Iterator that also calls Consumer.accept(Object) on each object provided by the given Iterator.
  • Constructor Details

    • ConsumingIterator

      public ConsumingIterator(Iterator<E> iterator, Consumer<E> consumer)
  • Method Details

    • hasNext

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

      public E next()
      Specified by:
      next in interface Iterator<E>
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<E>