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

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

问题描述

我觉得我的问题和这个类似:如何实现具有多个键的地图? 但有一个重要的区别.在那个问题中(如果我对它的理解是正确的,请告诉我如果不是),密钥应该始终是唯一的.我想要一个 Map 的形式:我的地图其中键不一定是唯一的.如果这没有意义,我基本上想要一个二维数组,但不是通过坐标引用元素,我想通过对象对引用它们.

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.

有人对可以使用的库或自己实现此功能的好方法有任何想法吗?就库而言,我看过 Apache Commons 和 Guava,似乎都没有我想要的.

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.

推荐答案

Table 数据结构似乎可以满足您通过一对对象引用值的要求.

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天全站免登陆