One more pass on flatMap/mapMulti (original) (raw)

Brian Goetz brian.goetz at oracle.com
Thu Jan 10 07:54:27 PST 2013


Downstream:

 /** A collector for values associated with a given input.  Values 

can be * yielded individually, or in aggregates such as collections, arrays, or * streams; aggregates are flattened, so that yielding an array containing * [1, 2] is equivalent to yield(1); yield(2). */ interface Downstream { void yield(U element);

     default void yield(Collection<U> collection) {
         for (U u : collection)
             yield(u);
     }

     default void yield(U[] array) {
         for (U u : array)
             yield(u);
     }

     default void yield(Stream<U> stream) {
         stream.forEach(this::yield);
     }
 }

The basic idea is that this is a collector for values. It was at one point called "collector" but now we have something else called Collector.

On 1/10/2013 10:35 AM, Remi Forax wrote:

On 01/10/2013 04:10 PM, Brian Goetz wrote:

One more simplification: we don't really need a custom type SAM for Multifunction. We can rewrite mapMulti as:

mapMulti(BiBlock<Downstream, T>)) and move the Downstream class declaration to Stream, and XxxMultifunction go away. what Downstream is ?

mapMulti is still not a great name. How about "explode" ? yes, explode is better. Rémi



More information about the lambda-libs-spec-observers mailing list