Zhong Yu zhong.j.yu at
Thu Jun 13 08:03:17 PDT 2013

On Thu, Jun 13, 2013 at 6:16 AM, Peter Levart <peter.levart at> wrote:
> With the advent of new functional types in java.util.function and new
> default method Map.forEach(), I wonder if it has been considered to add
> the following interface to standard library:
> public interface BiIterable<T, U> {
>      void forEach(BiConsumer<? super T, ? super U> action);
> }
> Which could be used as a super-interface for Map:
> public interface Map<K,V> extends BiIterable<K, V> { ...
> ... in analogous way that Iterable<T> is super-interface of Collection<T>.
> Iterable<T> supports external iteration from day one, and now it also
> supports internal iteration by the way of default method with optimized
> implementations in JDK classes that show improved performance. For
> BiIterable<T, U> internal iteration is actually the only alternative,

> since it avoids boxing

I don't think we should be overly obsessed with avoiding object
creation at the cost of extremely ugly APIs.

> of arguments into a Pair.

I wish Java could get a Pair. The arguments against Pair don't make
any more sense than arguments against int or String. Or BiSomething -
you can't say Pair is bad, but Bi is good, both words mean two-ness.

Zhong Yu

More information about the lambda-dev mailing list