Collector's accumulator

Paul Sandoz paul.sandoz at oracle.com
Thu Apr 4 01:27:37 PDT 2013


On Apr 4, 2013, at 10:10 AM, Paul Sandoz <paul.sandoz at oracle.com> wrote:

> 
> On Apr 3, 2013, at 7:36 PM, Jose <jgetino at telefonica.net> wrote:
> 
>> In the days of the earliest builds, I asked for something like this:
>> 
>> 
>> polyline.nodes().cumulate((p0,p1)->new Segment(p0,p1))
>> 
>> 
>> to get the segments of a polyline, out from the vertices. 
>> 
>> 
>> I read the docs of the b83 but is seems that the Collector accumulator 
>> does not support bifuncions on the form:
>> 
>>              (U,U)-->V
>> 
>> but only mixed type arguments, (V,U)-->V.
>> 
> 
> U is the element type and V is the result type i.e. the accumulator accumulates results :-) it does not do anything with pairs of elements.
> 
> One trick is to change V from a Segment to something that holds them e.g. SegmentList. But it is harder for parallel evaluation to combine two SegmentList instances since you do not know the index in the stream of each vertex.
> 

Ah, i forgot these would be overlapping pairs, so you don't need the index. To combine two SegmentList instances you just need to create a new pair at the join e.g. add a new pair to the left of the left segment list then add all segments from the right segment list.

Paul.


More information about the lambda-dev mailing list