Class PeekableIterator<Object>

java.lang.Object
htsjdk.samtools.util.PeekableIterator<Object>
All Implemented Interfaces:
CloseableIterator<Object>, Closeable, AutoCloseable, Iterator<Object>
Direct Known Subclasses:
SamPairUtil.SetMateInfoIterator

public class PeekableIterator<Object> extends Object implements CloseableIterator<Object>
Generic Closable Iterator that allows you to peek at the next value before calling next
  • Constructor Details

    • PeekableIterator

      public PeekableIterator(Iterator<Object> iterator)
      Constructs a new iterator that wraps the supplied iterator.
  • Method Details

    • close

      public void close()
      Closes the underlying iterator.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface CloseableIterator<Object>
    • hasNext

      public boolean hasNext()
      True if there are more items, in which case both next() and peek() will return a value.
      Specified by:
      hasNext in interface Iterator<Object>
    • next

      public Object next()
      Returns the next object and advances the iterator.
      Specified by:
      next in interface Iterator<Object>
    • peek

      public Object peek()
      Returns the next object but does not advance the iterator. Subsequent calls to peek() and next() will return the same object.
    • remove

      public void remove()
      Unsupported Operation.
      Specified by:
      remove in interface Iterator<Object>