BiIterable?
Ali Ebrahimi
ali.ebrahimi1781 at gmail.com
Thu Jun 13 05:40:07 PDT 2013
what about Iterable<Entry<K,V>>:
public interface Map<K,V> extends Iterable<Entry<K,V>> {
default Iterator<Entry<K,V>> iterator(){...}
.
}
with Iterable<Entry<K,V>> internal iteration is not the only alternative,
because you can now
for(Entry<K,V> e:map)
if we move stream and parallelStream methods to Iterable we can utilize
from stream framework:
map.stream().filter( e -> e.getKey().contains("somePattern")).map(e ->
e.getValue())....
What others think about this.
On Thu, Jun 13, 2013 at 3:46 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