Class PeekIterator<T>

java.lang.Object
htsjdk.samtools.util.PeekIterator<T>
All Implemented Interfaces:
Iterator<T>

public class PeekIterator<T> extends Object implements Iterator<T>
Wrapper around an iterator that enables non-destructive peeking at the next element that would be returned by next()
  • Constructor Details

    • PeekIterator

      public PeekIterator(Iterator<T> underlyingIterator)
  • Method Details

    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<T>
      Returns:
      true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)
    • next

      public T next()
      Specified by:
      next in interface Iterator<T>
      Returns:
      the next element in the iteration. Calling this method repeatedly until the hasNext() method returns false will return each element in the underlying collection exactly once.
    • peek

      public T peek()
      Returns:
      the next element in the iteration, but without removing it, so the next call to next() or peek() will return the same element as returned by the current call to peek().
    • remove

      public void remove()
      Unsupported
      Specified by:
      remove in interface Iterator<T>
    • getUnderlyingIterator

      public Iterator<T> getUnderlyingIterator()
      Returns:
      the iterator wrapped by this object.