Interface ClosableIterator<T>

All Superinterfaces:
Closeable, Iterator<T>, IteratorCloseable<T>
All Known Subinterfaces:
ExtendedIterator<T>, NodeIterator, NsIterator, ResIterator, RSIterator, StmtIterator, TripleIterator
All Known Implementing Classes:
ContNodeIteratorImpl, FilterIterator, LazyIterator, LPTopGoalIterator, Map1Iterator, MapFilterIterator, NiceIterator, NodeIteratorImpl, NsIteratorImpl, NullIterator, ObjectIterator, RandomOrderIterator, ResIteratorImpl, RSIteratorImpl, SafeTripleIterator, SeqNodeIteratorImpl, SingletonIterator, StmtIteratorImpl, StoreTripleIterator, TrackingTripleIterator, WrappedIterator

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.

  • Method Details

    • close

      void close()
      Close the iterator. Other operations on this iterator may now throw an exception. A ClosableIterator may be closed as many times as desired - the subsequent calls do nothing.
      Specified by:
      close in interface Closeable