- All Known Subinterfaces:
- All Known Implementing Classes:
public interface ClosableIterator<T> extends IteratorCloseable<T>An iterator which should be closed after use. Some iterators take up resources which should be free'd as soon as possible, eg large structures which can be discarded early, or external resources such as database cursors.
Users of ClosableIterators (and thus of ExtendedIterator) should close the iterator if they are done with it before it is exhausted (i.e. hasNext() is still true). If they do not, resources may leak, be reclaimed unpredictably or much later than convenient. It is harmless to close the iterator once it has become exhausted and to call close multiple times.
Implementors are encouraged to dispose of resources as soon as is convenient.