Package generic.util

Class WrappingPeekableIterator<T>

  • Type Parameters:
    T - the type of the iterator
    All Implemented Interfaces:
    PeekableIterator<T>, java.util.Iterator<T>

    public class WrappingPeekableIterator<T>
    extends java.lang.Object
    implements PeekableIterator<T>
    An implementation of PeekableIterator that can take a Java Iterator and wrap it to implement the PeekableIterator interface.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()  
      T next()  
      T peek()
      Returns the item that would be returned by calling Iterator.next(), but does not increment the iterator as next would.
      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

        forEachRemaining
    • Constructor Detail

      • WrappingPeekableIterator

        public WrappingPeekableIterator​(java.util.Iterator<T> iterator)
    • Method Detail

      • hasNext

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

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

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

        public T peek()
               throws java.util.NoSuchElementException
        Description copied from interface: PeekableIterator
        Returns the item that would be returned by calling Iterator.next(), but does not increment the iterator as next would.
        Specified by:
        peek in interface PeekableIterator<T>
        Returns:
        the item that would be returned by calling Iterator.next()
        Throws:
        java.util.NoSuchElementException