Package io.servicetalk.concurrent
Interface CloseableIterator<T>
-
- Type Parameters:
T
- the type of elements returned by thisCloseableIterator
.
- All Superinterfaces:
java.lang.AutoCloseable
,java.util.Iterator<T>
- All Known Subinterfaces:
BlockingIterator<T>
public interface CloseableIterator<T> extends java.util.Iterator<T>, java.lang.AutoCloseable
AnIterator
that is also anAutoCloseable
.This interface is meant to be used in places where an
Iterator
contains state that is required to be cleared irrespective of whether data from theIterator
is completely consumed (i.e.Iterator.hasNext()
is called till it returnsfalse
) or not. This interface provides a way for a user of such anIterator
to discard data, by callingAutoCloseable.close()
. When usingCloseableIterator
, it is expected that the user will either consume all the data from theIterator
or explicitly callAutoCloseable.close()
to dispose the remaining data.