ints(), longs(), doubles() <was> Re: Ranges
Howard Lovatt
howard.lovatt at gmail.com
Tue May 7 02:02:26 PDT 2013
I would propose that if you know the range size then do the ideal balanced
split and if you don't know the range size then treat the range like an
iterator and produce a right balanced tree. In most cases, like other
stream sources, you will know the size.
PS I am sure that 'your' version of the streams will have better
performance than mine and I am glad you are paying so much attention to
this important aspect.
On 7 May 2013 17:24, Paul Sandoz <paul.sandoz at oracle.com> wrote:
>
> 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.
>
>
--
-- Howard.
More information about the lambda-dev
mailing list