commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dipanjan Laha (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (COLLECTIONS-533) Add a MultiValuedLinkedHashMap to preserve insertion order
Date Mon, 20 Oct 2014 12:45:33 GMT

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

Dipanjan Laha commented on COLLECTIONS-533:
-------------------------------------------

Sorry I missed this earlier, but there is an issue with this implementation of just wrapping
a LinkedHashMap to get a MultiValuedLinkedHashMap.
The order of insertion will not be maintained across different keys. For example, in the code

{code}
    MultiValuedMap<String, String> map = new MultiValuedLinkedHashMap<>();
    map.put((K)"a", (V)"a1");
    map.put((K)"b", (V)"b1");
    map.put((K)"a", (V)"a2");

    MapIterator<String, String> mapIt = map.mapIterator();
{code}

the map iterator will not follow the insertion order and would return \{a,a1}, \{a,a2} &
\{b,b1} in order.

imho to get the correct behaviour we would need to implement the functionality (maintaining
a DoubleLinkedList) over MultiValuedHashMap instead of just wrapping LinkedHashMap.
Or if anyone can suggest an easier way to do this.



> Add a MultiValuedLinkedHashMap to preserve insertion order
> ----------------------------------------------------------
>
>                 Key: COLLECTIONS-533
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-533
>             Project: Commons Collections
>          Issue Type: New Feature
>          Components: Map
>            Reporter: Benedikt Ritter
>              Labels: github
>
> Placeholder ticket for https://github.com/apache/commons-collections/pull/3



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message