Iterable/Iterator.stream()
Sam Pullara
spullara at gmail.com
Sun Mar 24 12:32:15 PDT 2013
I was working with Brian on seeing how limit/substream
functionality[1] might be implemented and he suggested conversion to
Iterator was the right way to go about it. I had thought about that
solution but didn't find any obvious way to take an iterator and turn
it into a stream. It turns out it is in there, you just need to first
convert the iterator to a spliterator and then convert the spliterator
to a stream. So this brings me to revisit the whether we should have
these hanging off one of Iterable/Iterator directly or both.
My suggestion is to at least have it on Iterator so you can move
cleanly between the two worlds and it would also be easily
discoverable rather than having to do:
Streams.stream(Spliterators.spliteratorUnknownSize(iterator,
Spliterator.ORDERED))
Sam
[1] https://github.com/spullara/java-future-jdk8/blob/master/src/main/java/spullara/util/Limiter.java
More information about the lambda-libs-spec-experts
mailing list