Why doesn't Google Collections support MultiKeyMap, like Apache collections?

Is the Google solution similar to the solution for SortedMultiSet (stack question) or is it because there is no use MultiKeyMap?

I know that an alternative for MultiKeyMapcould be to use a custom class as a key that contains several keys as members of the class. On the contrary, I like the concept of specifying multiple keys when calling get MultiKeyMap.

The Apache version MultiKeyMapis great, but I skipped Generics a lot and therefore looked into the Google collection for its modern implementation. If someone has an idea why Google has not yet supported it or there is no better alternative, then answer.

+5
source share
3 answers

We have a very good implementation of a two-level map, which we call a "table" (K1 is the "row key" and K2 is the "column"), and we just did not get it all the same. However, the last two keys reduce the return.

+6
source

FYI, the accepted answer was given in March 2010, but as of September 2010 Guava included Table.

+9
source

, generics showstopper . , (K) (V). , , ( ).

For each class, you will need a class:

MultiKeyMap2<K1,K2,V>
MultiKeyMap3<K1,K2,K3,V>
MultiKeyMap4<K1,K2,K3,K4,V>
MultiKeyMap5<K1,K2,K3,K4,K5,V>

The main implementation basically does what you offer (using a custom class). However, he does not formally create a class for him, everything is included. This is truly an implementation detail. But for using Google collections, a custom class to perform the same action will work just as I am sure to implement hashCode () and equals ().

+2
source

All Articles