Class IterableOnceIterator<T>

java.lang.Object
htsjdk.samtools.util.IterableOnceIterator<T>
All Implemented Interfaces:
Closeable, AutoCloseable, Iterable<T>, Iterator<T>
Direct Known Subclasses:
SamLocusAndReferenceIterator

public abstract class IterableOnceIterator<T> extends Object implements Iterable<T>, Iterator<T>, Closeable
Abstract implementation of an iterator that also implements Iterable (to return itself) so that it can be used if for() loops. Only supports calling iterator() once since new iterators are not manufactured but the same object returned.
  • Constructor Details

    • IterableOnceIterator

      public IterableOnceIterator()
  • Method Details

    • iterator

      public Iterator<T> iterator()
      On the first call returns this object which is also an iterator. On subsequent calls throws an exception since new iterators cannot be generated.
      Specified by:
      iterator in interface Iterable<T>
    • remove

      public void remove()
      Operation not supported.
      Specified by:
      remove in interface Iterator<T>
    • close

      public void close() throws IOException
      Does nothing, intended to be overridden when needed.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException