Pure generators: stream bindings

Mike Duigou mike.duigou at oracle.com
Mon Sep 17 20:30:15 PDT 2012

On Sep 15 2012, at 12:50 , Aleksey Shipilev wrote:

> On 09/14/2012 08:20 PM, Mike Duigou wrote:
>>> The lesson I learned from this is, there is for having a couple of 
>>> standard generators in order to highlight these issues, and also
>>> to comply with the "rule of three".
>> Thank you for pointing out some of the documentation holes. I've made
>> a few improvements to the docs in this area recently but this
>> feedback gives us good indication of what the most confusing/poorly
>> described points are.
> Thanks Mike. Does this implementation of LongRange [1] makes sense? Is
> there something I've missed? BTW, it would be nice to have such the
> class among standard streams.

Looks useful and good sample code.

Some comments:

- relation of to/from could set the direction of iteration. ie. count down if to is smaller than from. Might be useful.

- LongRange should probably implement Streamable

- LongRange::sequential() should be LongRange::stream() 

- You should probably refactor out the common bits so that you can re-use them for other types of ranges.

- The naming of "ParallelPipeline" conflicts with the usage in java.util.streams for "pipeline" which is sequence of operations. Perhaps "RangeParallelStream"

- some fields could be final

- Look at the technique for splitting array range in java.util.streams.Streams. It's a little cleaner than what RangeSpliterator.split() uses

- RangeIterator.into() doesn't set the iterating flag. Draining elements with into is equivalent to calling iterator.


> -Aleksey.
> [1] http://shipilev.net/pub/jdk/lambda/LongRange.java

More information about the lambda-dev mailing list