I see there is a Multimap that allows duplicate values for a key http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/collect/Multimap.html
I also noticed guava has a Table which allows multiple keys, but not duplicated values. http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/collect/Table.html
I can't find anywhere where there is a "Table" that allows duplicated values, or a "Multimap" that allows multiple keys.
Is this something that exists already, or would I have to implement this myself?
I just want to implement a Multimap with 2 keys i.e. <K1, K2, Value>
There's nothing I'm aware of that supports that need. However, it's not terribly difficult to just e.g. use a Multimap<MyK1AndK2Pair, Value> where you write a custom pair class yourself, or conversely to use a Table<K1, K2, List<Value>> and manage things yourself.
What about nested maps?
Multimap<K1, Multimap<K2, Value>> doubleMultiMap = new HashMultiMap<>();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With