Subj : Re: Multi-dimensional data structure To : comp.programming From : Googmeister Date : Wed Oct 12 2005 05:59 am Adi wrote: > You're right and I have thought about it. There exists a java > implementation called MultikeyMap > http://jakarta.apache.org/commons/collections/apidocs-COLLECTIONS_3_1/org/apache/commons/collections/map/MultiKeyMap.html > > It's not a perfect solution because I now need to ensure that my keys > are sortable not to mention the additional (albeit small) overhead of > sorting everytime i call get or put. > > I was interested in a more elegant solution than that, if one exists. One approach is to take the xor of the three hashCodes and use this as the hashCode. You still have the (albeit small) overhead of sorting (or brute force checking) when you call get. The xor function is usually not a good idea with hash functions since xor(a, a, b) = xor(c, c, b), but depending on your application, it might work. Otherwise, you could consider another symmetric function to combine hashCodes. .