Remove cumulate from Stream interface (original) (raw)
Remi Forax forax at univ-mlv.fr
Wed Dec 5 10:47:32 PST 2012
- Previous message: Remove cumulate from Stream interface
- Next message: Remove cumulate from Stream interface
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 12/05/2012 04:05 PM, Brian Goetz wrote:
Only if you don't care about parallel,
damn it, my cover is ruined :)
and the whole value of cumulate is that prefix shows up everywhere in parallel algorithms.
Plus, your Mapper will violate the to-be-written specs about statefulness/side-effects in lambdas passed to functional stream methods.
Do you really want this overly restrictive wording for streams that are sequential ? I find this unrealistic, even if you try to specify this in the doc, nobody read the doc if not forced. Given that will not be enforced in the code, it will be only true on the paper.
Rémi
On 12/5/2012 9:33 AM, Remi Forax wrote: I maybe wrong but there is a simple way to implement cumulate() using map(), so I'm not sure cumulate pull its own weight.
Rémi public final Stream cumulate(final BinaryOperator operator) { return map(new Mapper<U,U>() { private Object accumulator = NOVALUE; @Override public U map(U element) { Object acc = accumulator; if (acc == NOVALUE) { return element; } acc = operator.operate((U)acc, element); accumulator = acc; return (U)acc; } }); }
- Previous message: Remove cumulate from Stream interface
- Next message: Remove cumulate from Stream interface
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the lambda-libs-spec-experts mailing list