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.AutoCloseableAnIteratorthat is also anAutoCloseable.This interface is meant to be used in places where an
Iteratorcontains state that is required to be cleared irrespective of whether data from theIteratoris completely consumed (i.e.Iterator.hasNext()is called till it returnsfalse) or not. This interface provides a way for a user of such anIteratorto discard data, by callingAutoCloseable.close(). When usingCloseableIterator, it is expected that the user will either consume all the data from theIteratoror explicitly callAutoCloseable.close()to dispose the remaining data.