commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From __matthewHawthorne <ma...@phreaker.net>
Subject Re: [collections] dup-key map and map intersections?
Date Mon, 19 Jan 2004 14:23:29 GMT
Phillip Rhodes wrote:
 > 1)  Is there any Map type of Container that allows me to have
 > duplicate keys that have different payloads (different values in the
 > value portion?
 >
 > 2)  Is there a way that I can do an Intersection between two of these
 > maps and get the value portion of the map into an Collection type of
 > container?


Take a look at the org.apache.commons.collections.MultiHashMap class.  I 
think this will solve your 1st problem.

As for your 2nd problem, I don't know of a solution that is as 
convenient as your example.  However, you could do:

((Collection)map1.get("1)").retainAll((Collection)map2.get("1"))

And I think that would do what you want.


Maybe a patch adding

MultiMap.retainAll(Collection)
MultiMap.removeAll(Collection)

would be considered?



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message