Package htsjdk.samtools.util
Interface CloseableIterator<T>
-
- All Superinterfaces:
AutoCloseable
,Closeable
,Iterator<T>
- All Known Subinterfaces:
CloseableTribbleIterator<T>
,SAMRecordIterator
,VCFIterator
- All Known Implementing Classes:
AbstractLocusIterator
,AsyncBufferedIterator
,BAMFileReader.BAMQueryFilteringIterator
,CRAMIterator
,DelegatingIterator
,DownsamplingIterator
,DuplicateSetIterator
,EdgeReadIterator
,FilteringIterator
,FilteringIterator
,FilteringSamIterator
,FilteringVariantContextIterator
,MergingIterator
,MergingSamRecordIterator
,PeekableIterator
,SamLocusIterator
,SamPairUtil.SetMateInfoIterator
,SamReader.AssertingIterator
,SAMRecordPrefetchingIterator
,SRAAlignmentIterator
,SRAIterator
public interface CloseableIterator<T> extends Iterator<T>, Closeable
This interface is used by iterators that use releasable resources during iteration. The consumer of a CloseableIterator should ensure that the close() method is always called, for example by putting such a call in a finally block. Two conventions should be followed by all implementors of CloseableIterator: 1) The close() method should be idempotent: calling close() twice should have no effect. 2) When hasNext() returns false, the iterator implementation should automatically close itself. The latter makes it somewhat safer for consumers to use the for loop syntax for iteration: for (Type obj : getCloseableIterator()) { ... }
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
close()
Should be implemented to close/release any underlying resources.default Stream<T>
stream()
Returns a Stream that will consume from the underlying iterator.default List<T>
toList()
Consumes the contents of the iterator and returns it as a List.-
Methods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next, remove
-
-
-
-
Method Detail
-
close
void close()
Should be implemented to close/release any underlying resources.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
-