[ 
https://issues.apache.org/jira/browse/COLLECTIONS-237?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12928440#action_12928440
 ] 

Grant Overby commented on COLLECTIONS-237:
------------------------------------------

I have a possible solution (perhaps unacceptable) that was coded for in-house 
use.

In this solution, MultiMap.entrySet returns a flattened "set" that violates the 
general contract of set by allowing two Entry that are .equals . It behaves as 
an IdentitySet, similar to th keys of java.util.IdentityHashMap .

Another note is that the set supports .remove and if all values for a key are 
removed, the key is also removed. I'm unsure if the removal of the key is 
desired. It would be trivial to change.

If this solution is desired for the library, I'll work it up as a proper patch.

> MultiValueMap: behavior of entrySet().iterator() is not the expected one
> ------------------------------------------------------------------------
>
>                 Key: COLLECTIONS-237
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-237
>             Project: Commons Collections
>          Issue Type: Bug
>          Components: Map
>    Affects Versions: 3.2
>            Reporter: Nils Kaiser
>             Fix For: 4.x
>
>
> The entrySet() method of the MultiValueMap delegates the entrySet() call to 
> the decorated map, which is HashMap by default. The default hashmap iterator 
> is used, which causes the iterator to return one Map.Entry for every key. The 
> value returned for the key is an ArrayList, and not the value of the entry 
> which was put into the map.
> The expected behavior would be the iterator to return the whole set of 
> entries in the map, which requires iteration over the different array lists 
> contained in the decorated map.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to