Re: Map.Entry methods for streams

2016-01-15 Thread Tagir F. Valeev
Hello! Note that having single swap() method which just swaps key and value in addition to withKey/withValue covers this use case: Map> gad = dag.entrySet() .stream() .flatMap(e -> e.getValue().stream().map(e.swap()::withKey)) .collect(groupingBy(Entry::getKey, mapping(En

Re: Map.Entry methods for streams

2016-01-15 Thread Stephen Colebourne
So, this proposal is essentially trying to add something small to JDK 9 in advance of the long wait for value types and a full solution to the problem space. A stream of Map.Entry is painful today, and my idea or Remi's would definitely assist without pushing the API too far (I'm not such a fan of

RE: Map.Entry methods for streams

2016-01-15 Thread Timo Kinnunen
ntry::getKey, mapping(Entry::getValue, toList(; -- Have a nice day, Timo Sent from Mail for Windows 10 From: Peter Levart Sent: Friday, January 15, 2016 16:44 To: Remi Forax; Stephen Colebourne Cc: core-libs-dev Subject: Re: Map.Entry methods for streams Hi, Another possibility woul

Re: Map.Entry methods for streams

2016-01-15 Thread Paul Sandoz
Hi, We have had multiple attempts at a BiStream for references. Mike had quite a good one. I thought my last attempt was rather good too :-) it avoided boxing on critical paths, while avoiding much bifurcation of the Spliterator API, and supported some nice use-cases. However, it would likely

Re: Map.Entry methods for streams

2016-01-15 Thread Tagir F. Valeev
Hello! SC> Finally, the Collectors class could do with a new method entriesToMap() SC> that collects a stream of Map.Entry back into a Map. I was thinking about adding such collector into my library and checked StackOverflow to understand the useful scenarios. Seems that having entriesToMap() col

Re: Map.Entry methods for streams

2016-01-15 Thread Peter Levart
Hi, Another possibility would be to introduce the following default methods to Map.Entry: public interface Map.Entry { ... default Map.Entry withKey(L key) { ... } default Map.Entry withValue(W value) { ... } } Usage would then look like: map.entrySet().stream().map(e -> e.withValu

Re: Map.Entry methods for streams

2016-01-15 Thread Remi Forax
Hi Stephan, mixing methods that create a new entry (your mapValue) with one that mutate the current entry (setValue) is still a bad idea. I think it's better to introduce a static method in Map.Entry like this: public static Function, Map.Entry> mapValue(Function valueMapper) { return ent