java多映射列表 [英] java multi mapping arraylist
问题描述
是否可以将键映射到多维数组列表。有些事情像下面的例子..
Is it possible to map key to Multi Dimensional Array List. Some thing like following example..
Map<K,V>
其中K是字母表列表的键,V是多维数组列表或正常数组列表存储单词列表。有些事情就像一个读取字典文件的应用程序。我想看一个例子。示例可以是与Map和Multi Dimensional Array-list相关的任何内容。或者还有其他有效的方式来实现集合?我从来没有使用过这样的实现,所以如果已经有一个与我的QA相关的线程,请发布链接。
Where K is key for list of alphabet and V is a multi dimensional array list or normal array list that stores list of word. Some thing like a application that reads a dictionary file. I want to see an example. Example can be anything related to Map and Multi Dimensional Array-list. Or is there any other efficient way to implement collection? I have never used such implementations so if there is already a thread related to mine QA please post the link.
推荐答案
您可以使用 Guava's Multimap的,如果要将多个值与单个键相关联。您需要 ArrayListMultimap 对于您的具体情况。
You can use Guava's Multimap's if you want to associate multiple values with a single key. You need ArrayListMultimap for your specific case.
示例
ListMultimap<String, String> dict= new ArrayListMultimap<String, String>();
dict.put("key 1", "value 1");
dict.put("key 1", "value 2");
dict.put("key 2", "value 1");
这篇关于java多映射列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!