T
- type of elements returned by the iteratorpublic interface ClosableIterable<T> extends Iterable<T>, AutoCloseable
Iterable
which should be AutoCloseable.close()
d after use.
A good pattern to use this iterator is with an outer try-with-resources
block:
for (ClosableIterable<Triple> triples : graph.iterate()) {
for (Triple t : triples) {
return t; // OK to terminate for-loop early
}
}
The above will ensure that underlying resources are closed even if
the iteration does not exhaust all triples.
forEach, iterator, spliterator
close
Copyright © 2015–2018 The Apache Software Foundation. All rights reserved.