[concurrency-interest] forkjoin.ParallelArray and friends

Doug Lea dl at cs.oswego.edu
Tue Aug 28 06:45:53 EDT 2007

I wrote:
> Right. If you want to apply functions F and G, then you
> must define a function/object GofF that combines them itself
> to hand to withMapping.

Actually, we might as well be nice to users and
automate this. We can not only supply in class Ops
classes like...
   class CompositeMapper<T,U,V> implements Mapper<T,V> {
     public CompositeMapper(Mapper<? super T, ? extends U> m1,
                            Mapper<? super U, ? extends V> m2) ...
     public V map(T t) { return m2(m1(t)); }

...but also allow nested withMapping's to construct them,
relieving people of one bit of the unpleasantness of manually
arranging this.
Especially since the WithMapping style eliminates a potential
source of error, of forgetting whether a CompositeMapper<T,T,T>
applies m1 first or m2 first.

Similarly with Predicates and a few others.

Neal: Thanks for the suggestion :-)


More information about the Concurrency-interest mailing list