You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2002/10/19 22:31:43 UTC
DO NOT REPLY [Bug 13786] New: -
Proposal for change in MultiHashMap
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13786>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13786
Proposal for change in MultiHashMap
Summary: Proposal for change in MultiHashMap
Product: Commons
Version: Nightly Builds
Platform: Other
OS/Version: Other
Status: NEW
Severity: Enhancement
Priority: Other
Component: Collections
AssignedTo: commons-dev@jakarta.apache.org
ReportedBy: sye@mail.ru
Current implementation of MultiHashMap has one problem with notion of equality.
Namely, when for some key some value is added, and then removed from MultiMap,
and this value was only value, that was put for this key
than multimap wouldn't be equal to other multimap with same values of key/value
pairs, in which this new value was not added.
This can be demonstrated by following test (can be added to
TestMultiHashMap.testMapEquals):
public void testMapEquals() {
MultiHashMap one = new MultiHashMap();
Integer value = new Integer(1);
one.put("One", value);
one.remove("One", value);
MultiHashMap two = new MultiHashMap();
assertEquals(two, one);
}
Suggested fix for this problem is the following change in code of
MultiHashMap.remove(Object key, Object value).
public Object remove( Object key, Object item )
{
ArrayList valuesForKey = (ArrayList) super.get( key );
if ( valuesForKey == null )
return null;
valuesForKey.remove( item );
//start of change
if(valuesForKey.isEmpty()){
remove(key);
}
//end of change
return item;
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>