ints(), longs(), doubles() <was> Re: Ranges
Paul Sandoz
paul.sandoz at oracle.com
Tue May 7 00:24:48 PDT 2013
On May 7, 2013, at 1:44 AM, Howard Lovatt <howard.lovatt at gmail.com> wrote:
> In my stream library the splits are always the same size (for a given stream), therefore knowing the overall size isn't important. From your reply I take it that lambda streams would like to know the size. For loops that use to(int) and optionally step(int) it is, obviously, easy to provide size and these are the most common use cases. However it would have to be carefully documented that whileTrue(lambda) and step(lambda) slow down parallel processing.
>
The underlying point is being able to create a balanced tree for computation. If the size is not known the range cannot be efficiently split in two, and that sub-range cannot be split in two etc etc.
Generally most spliterator implementations will create balanced trees, others, like for maps, will create mostly balanced trees based on size estimates, and finally for iterators or sequentially sources it will be right-balanced trees.
Paul.
More information about the lambda-dev
mailing list