maidh91 / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Add a Map<K,V> Maps.combinedValueIndex(Iterable<I>, Function<I,K>, Combiner<I,V>) for combination of multiple inputs per key into one value #330

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I would like something to help with transforming Iterable etc to a map 
where multiple inputs for a key can be combined into a single value.

It's like uniqueIndex, but instead of throwing an exception on the second 
time a key is calculated from the input, it is then sent to the Combiner to 
be resolved:

V Combiner.combine(I newInput, V existingValue);

(this would be called the first time too, where existingValue is null).

The separation of Input and Value may or may not be necessary. I think it's 
probably valid to only combine V values, and then transform the resultant 
Map.

Original issue reported on code.google.com by stephen....@gmail.com on 24 Feb 2010 at 2:15

GoogleCodeExporter commented 9 years ago
This sort of thing is most generally useful for mapping by "latest/earliest" 
value per 
calculated key, but affords itself to other uses (e.g. implementation of 
first/last in 
wins and other filterable criteria)

Original comment by stephen....@gmail.com on 24 Feb 2010 at 2:21

GoogleCodeExporter commented 9 years ago
Also, just to make sure we're not just chasing after a sorted-set-multimap 
first idea, 
it's good for set functions (sums, averages etc)

Original comment by stephen....@gmail.com on 24 Feb 2010 at 2:57

GoogleCodeExporter commented 9 years ago

Original comment by fry@google.com on 28 Jan 2011 at 3:59

GoogleCodeExporter commented 9 years ago

Original comment by kevinb@google.com on 13 Jul 2011 at 6:18

GoogleCodeExporter commented 9 years ago
We are not in favor of taking Guava further in this functional direction and 
are holding off on adding any new functional types like Consumer,Reducer,etc.  
You might want to use Functional Java (but that's not a recommendation).

The world will look much different in Java 8 and will be much friendlier to 
this style of programming.

Original comment by kevinb@google.com on 28 Jul 2011 at 8:29

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:15

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:10