单值映射Java的多个键 [英] Multiple Keys to Single Value Map Java

查看:160
本文介绍了单值映射Java的多个键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为我的问题与此类似:如何实施具有多个键的地图,但具有重要的区别。在这个问题上(如果我对它的理解是正确的,请让我知道,如果不是),钥匙应该永远是独一无二的。我想要一个地图的形式:
MyMap
其中的键不一定是唯一的。如果没有意义,我基本上想要一个二维数组,而不是通过坐标来引用元素,我想用对对象来引用它们。



解决方案

表格数据Guava的结构似乎满足了您通过一对物体引用价值的要求。


I think my question is similar to this one: How to implement a Map with multiple keys? but with an important difference. In that question (if my understanding of it is correct, please let me know if it isn't), the keys were supposed to always be unique. I want to have a Map in the form: MyMap where the keys aren't necessarily unique. If that doesn't make sense, I basically want a 2 dimensional array, but rather than refering to elements by coordinates, I want to refer to them by pairs of objects.

Anyone have any ideas as to either a library where this works or a good way to implement this myself? As far as libraries go, I've looked at Apache Commons and Guava, neither seem to have what I want.

解决方案

The Table data structure in Guava seems to meet you requirement of refering to a value by a pair of objects.

这篇关于单值映射Java的多个键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆