0

I need to use some kind of double map in my project. I can imagine this as Map with common key and triple value, but maybe there's better option. Is there any implementations of this kind of map? Maybe some free library?

another-programmer
  • 841
  • 13
  • 37
  • Add some sample data. – xyz Jul 25 '15 at 05:34
  • Triple value, as in 3 values for 1 key? Or multiple values for 1 key? You could either create a new type `NewValue` (to create objects which contain those values), then use ``. Or you could use a `List` as the value, which can contain multiple elements. – Vince Jul 25 '15 at 05:34
  • You mean a multimap ? - http://commons.apache.org/proper/commons-collections/javadocs/api-3.2.1/org/apache/commons/collections/MultiMap.html – Prahalad Deshpande Jul 25 '15 at 05:36
  • I thought about creating new type with 3 fields and then just use Map with this type, but it looks a little awkward. – another-programmer Jul 25 '15 at 06:20
  • Multimap is not really what I need, I need exactly 3 values for one key, not the Collection – another-programmer Jul 25 '15 at 06:21

2 Answers2

1

Create two small Java POJOs for title and value attributes MyKey and MyValue and you can now have Map<MyKey, MyValue> in this case you can extend the attributes of the Key and Value in future.

akash
  • 22,664
  • 11
  • 59
  • 87
1

You could use a Triplet from http://www.javatuples.org/.

Or, you could create your own class, like shown here: https://stackoverflow.com/a/2671052/5066232.

Community
  • 1
  • 1
Jason Yang
  • 130
  • 8