Details
-
New Feature
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
A Graph is a collection of triples, yet it does not support the Iterable interface, and thus can't be used in a classic for-each loop like:
for (Triple t : graph) { System.out.println(t); }
instead you are forced to use .getTriples() and either .sequential().forEach, or the awkward casting with ::iterator
http://stackoverflow.com/questions/20129762/why-does-streamt-not-implement-iterablet
Note that Stream is not Iterable, as it can only be iterated over once.. (I often find my self adding a function like iterable() to work around such cases).
My proposal is simply to add the interface Iterable and have a default implementation that calls getTriples().iterator().
It could be that there are other solutions that also work with the filtered getTriples() - e.g. some kind of Collector that is iterable?