explode
Tim Peierls
tim at peierls.net
Fri Feb 8 12:55:00 PST 2013
Modulo the names, seems reasonable. Don't know why the extra static method,
but it doesn't wreck things for me.
On Fri, Feb 8, 2013 at 10:47 AM, Brian Goetz <brian.goetz at oracle.com> wrote:
> OK, just to put it all down on "paper" where flatMap landed...are we OK
> with this?
>
> java.util.stream.FlatMapper:
>
> public interface FlatMapper<T, U> {
> void explodeInto(T element, Consumer<U> sink);
>
> interface ToInt<T> {
> void explodeInto(T element, IntConsumer sink);
> }
>
> interface ToLong<T> {
> void explodeInto(T element, LongConsumer sink);
> }
>
> interface ToDouble<T> {
> void explodeInto(T element, DoubleConsumer sink);
> }
>
> interface OfIntToInt {
> void explodeInto(int element, IntConsumer sink);
> }
>
> interface OfLongToLong {
> void explodeInto(long element, LongConsumer sink);
> }
>
> interface OfDoubleToDouble {
> void explodeInto(double element, DoubleConsumer sink);
> }
> }
>
> In Stream:
>
> <R> Stream<R> flatMap(Function<T, Stream<? extends R>> mapper);
>
> <R> Stream<R> flatMap(FlatMapper<? super T, R> mapper);
>
> IntStream flatMap(FlatMapper.ToInt<? super T> mapper);
> LongStream flatMap(FlatMapper.ToLong<? super T> mapper);
> DoubleStream flatMap(FlatMapper.ToDouble<? super T> mapper);
>
> In IntStream (similar for {Double,Long}Stream):
>
> IntStream flatMap(IntFunction<? extends IntStream> mapper);
> IntStream flatMap(FlatMapper.OfIntToInt mapper);
>
>
> And Remi wants one more static helper method in FlatMap:
>
>
> public static <T, U> FlatMapper<T, U>
> explodeCollection(Function<? super T, ? extends Collection<? extends U>>
> function)
>
>
> I think this wraps up the explosive section of our program?
>
>
>
> On 2/6/2013 7:05 PM, Kevin Bourrillion wrote:
>
>> On Wed, Feb 6, 2013 at 3:30 PM, Brian Goetz <brian.goetz at oracle.com
>> <mailto:brian.goetz at oracle.com**>> wrote:
>>
>> Stream<U> flatMap(FlatMapper<T, U>)
>>
>> Stream<U> flatMap(Function<T, Stream<U>>)
>>
>>
>> To make sure I understand: would these two behave identically? Would
>> they imaginably perform comparably?
>>
>> foos.stream().flatMap((t, consumer) ->
>> t.somethingThatGivesAStream().**forEach(consumer))
>> foos.stream().flatMap(t -> t.somethingThatGivesAStream())
>>
>> Second question, why "FlatMapper.OfInt" here, but "IntSupplier" etc.
>> elsewhere?
>>
>> --
>> Kevin Bourrillion | Java Librarian | Google, Inc. |kevinb at google.com
>> <mailto:kevinb at google.com>
>>
>
More information about the lambda-libs-spec-observers
mailing list