commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tom Parker (JIRA)" <>
Subject [jira] Commented: (COLLECTIONS-332) ListOrderedMap not respecting underlying list
Date Fri, 14 Aug 2009 03:42:14 GMT


Tom Parker commented on COLLECTIONS-332:

Per my note to the commons user list, I was hoping for either updated docs or a code change,
but I think one of the two would be good.

Looking for a code change, I agree casting is nasty and would recommend against it... it's
very ugly to get all cases correct.  For example, a TreeMap sorted in case insensitive order
also breaks ListOrderedMap because it also fails to use .equals().  

Before this is turned into a documentation bug or feature request, I'd like to note a potential
solution simply depends upon how much of a performance hit one is willing to take.

Object result = getMap().remove(key);
for (Iterator<Object> it = insertOrder.iterator(); it.hasNext();) \{
  if (!getMap().containsKey( \{ //This respects equality as defined by the underlying
return result;

...would seem to be universal (if slower since it effectively trades a .equals() for a .containsKey()
call) [and yes, getMap() should be extracted to a local variable]

> ListOrderedMap not respecting underlying list
> ---------------------------------------------
>                 Key: COLLECTIONS-332
>                 URL:
>             Project: Commons Collections
>          Issue Type: Bug
>          Components: Map
>            Reporter: Tom Parker
>            Priority: Minor
>         Attachments:
> When decorating either CaseInsensitiveMap or IdentityMap (and I believe this will impact
any java.util.TreeMap built with a non-.equals() Comparator), ListOrderedMap responds inconsistently
with the underlying map.  The ordering seems to be operating off .equals() rather than the
actual contents of the underlying map. 

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

View raw message