Collapsing stream()/parallel() into a single stream(Hint)
Paul Benedict
pbenedict at apache.org
Mon Dec 10 14:28:43 PST 2012
While reading the Collection API, I was surprised to see both stream()
and parallel() present. After seeing stream(), I was not expecting
another method to return streams -- it seemed like the former was the
"de facto" way of creating one.
I understand the EG is currently discussing something similar (thread
"Constructing parallel streams"). Remi proposed a ParallelizableStream
interface, but I think a more straightforward solution is to provide
stream() and a stream(Hint). The first would construct a stream
according to the implementation's choice. Maybe this is too
restrictive, but the latter is more flexible. You pass in a hint --
perhaps StreamFlags? -- to request the kind of stream you want
constructed. Either the implementation can satisfy your demands or
throw an Exception.
Paul
More information about the lambda-libs-spec-comments
mailing list