Class IteratorMapper<E,​S>

  • All Implemented Interfaces:
    java.lang.AutoCloseable, java.util.Iterator<S>, CloseableIterator<S>
    Direct Known Subclasses:

    public class IteratorMapper<E,​S>
    extends java.lang.Object
    implements CloseableIterator<S>
    A iterator that maps each value to the output of the Function. Note that the remove is supported if the iterator originally supported remove. This iterator implements CloseableIterator and will close the provided iterator if it also implemented CloseableIterator.
    William Burns
    • Constructor Summary

      Constructor Description
      IteratorMapper​(java.util.Iterator<? extends E> iterator, java.util.function.Function<? super E,​? extends S> function)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      boolean hasNext()  
      S next()  
      void remove()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

    • Constructor Detail

      • IteratorMapper

        public IteratorMapper​(java.util.Iterator<? extends E> iterator,
                              java.util.function.Function<? super E,​? extends S> function)
    • Method Detail

      • hasNext

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

        public S next()
        Specified by:
        next in interface java.util.Iterator<E>
      • remove

        public void remove()
        Specified by:
        remove in interface java.util.Iterator<E>
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface CloseableIterator<E>