Package htsjdk.samtools.util

# 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 Summary

Constructors
Constructor
Description
`IterableOnceIterator()`

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
Does nothing, intended to be overridden when needed.
`Iterator<T>`
`iterator()`
On the first call returns this object which is also an iterator.
`void`
`remove()`
Operation not supported.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface java.lang.Iterable

`forEach, spliterator`

### Methods inherited from interface java.util.Iterator

`forEachRemaining, hasNext, next`

## 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`