commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "matthew.hawthorne" <ma...@apache.org>
Subject Re: [collections] MultiKeyMap
Date Mon, 12 Apr 2004 07:35:36 GMT
Michael Heuer wrote:
> Might you also be able to use an unmutable MultiKey for storage in the
> hashed map and a mutable MultiKey for lookups, with matching equals and
> hashCode implementations?
> 
>   void put(Obj a, Obj b, ...) {
>     map.put(new MultiKey(a, b, ..));
>   }
> 
>   private MutableMultiKey lookupKey = new MutableMultiKey();
> 
>   Object get(Obj a, Obj b, ...) {
>     lookupKey.setKeys(a, b, ..));
>     return map.get(lookupKey);
>   }
> 
> I have something that works this way lying around somewhere.

I'm not 100% sure, but I don't think this is thread safe, since multiple
threads may be calling the get method at the same time and thus
modifying the lookupKey instance var.

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


Mime
View raw message