Re: [collections] MultiValuedMap interface discussion

2014-03-31 Thread Thomas Neidhart
On 03/28/2014 12:47 AM, Ted Dunning wrote: > Following Guava on this has something to be said for it. > > https://code.google.com/p/guava-libraries/wiki/NewCollectionTypesExplained > > Their decision is that Multimap#get returns a collection always. If there > are no values, then an empty collec

Re: [collections] MultiValuedMap interface discussion

2014-03-28 Thread Dipanjan Laha
Thanks Ted for pointing to this. I checked out the guavas Multimap and if I understand correctly, they are returning a wrapped Collection with an internal reference to the Multimap. The basic behavior is - When add is triggered on the collection, they create the mapping in their Multimap if it is

Re: [collections] MultiValuedMap interface discussion

2014-03-27 Thread Ted Dunning
Following Guava on this has something to be said for it. https://code.google.com/p/guava-libraries/wiki/NewCollectionTypesExplained Their decision is that Multimap#get returns a collection always. If there are no values, then an empty collection is returned so that you can always do m.get

Re: [collections] MultiValuedMap interface discussion

2014-03-27 Thread Paul Benedict
The downside of it returning an empty collection is you either have (1) to instantiate a collection just to say you have nothing or (2) you use an immutable collection. #1 is bad in itself and #2 is only as bad if the collection is otherwise writable. For example, it would be really strange for the

[collections] MultiValuedMap interface discussion

2014-03-27 Thread Thomas Neidhart
Hi, we are currently working on a new MultiValuedMap interface for collections, see https://issues.apache.org/jira/browse/COLLECTIONS-508. During the work we stumbled across an issue we would like to discuss. The MultiValuedMap is basically a Map that can hold multiple values associated to a give