Encounter order
Paul Sandoz
paul.sandoz at oracle.com
Tue Oct 23 04:11:53 PDT 2012
On Oct 23, 2012, at 8:07 AM, Joe Bowbeer <joe.bowbeer at gmail.com> wrote:
>
>> Or, if I wanted to "preserve" the order, I would zip-with-index before
>>> parallel execution.
>>>
>>
>> Does that mean you assume that reducing functions passed to reduce are
>> necessarily commutative?
>>
>> What about
>>
>> array.parallel().sorted().**toArray()
>>
>> ? Would you expect the result to appear in the array in sorted order?
>>
>
>
> After .parallel(), I would make no assumptions about order, but after
> .sorted(), I would expect the order to be sorted.
>
What about:
sortedList = list.parallel().sorted.into(new ArrayList<>());
// Is the filtered list sorted or does it need to be re-sorted?
filteredList = sortedList.parallel().filter(...).into(new ArrayList<>);
or:
TreeSet ts = ...
filteredList = ts.parallel().filter(...).into(new ArrayList<>());
The cost of re-sorting is likely to be more expensive than preserving the order.
Paul.
> I'm curious to know what other people think.
>
More information about the lambda-libs-spec-observers
mailing list