commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen Colebourne <scolebou...@btopenworld.com>
Subject Re: [Collections] MultiHashMap - retrieving values in the order in which they were added
Date Fri, 12 Aug 2005 08:13:15 GMT
Alice Boxhall wrote:
> Just a quick question re MultiHashMap:
> For my current project I need to be able to ensure that if I do
> 
> map.put("foo", a);
> map.put("foo", b);
> ((Collection)map.get("foo")).iterator();
> 
> I will get a and b back in that order. Obviously with the current 
> implementation this will be the case, but I was wondering if there was 
> some way that I could ensure that in case the implementation changes.
> 
> If not, no big deal, I can easily work around it.

1) there are no plans to change this.

2) IIRC there is a protected method in MultiHahsMap that returns the new 
collection (so you can subclass and force it)

3) You might want to try the new and improved MultiValueMap in the map 
subpackage (not released yet). It allows you much greater control over 
this type of class, and is the designated replacement for MultiHashMap.

Stephen

---------------------------------------------------------------------
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