BiIterable?

Howard Lovatt howard.lovatt at gmail.com
Thu Jun 13 05:42:09 PDT 2013


+1

Sent from my iPad

On 13/06/2013, at 9:16 PM, Peter Levart <peter.levart at gmail.com> 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 of arguments into a Pair.
> 
> 
> What do you think?
> 
> Regards, Peter
> 
> 


More information about the lambda-dev mailing list