在Android在Java中如何创建一个Multimap之 [英] How can I create a Multimap in Java on Android

查看:298
本文介绍了在Android在Java中如何创建一个Multimap之的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在哪里可以找到multimap中的Java,将工作在Android上的一种实现,而不包括任何其他类等我发现都需要需要其他的东西其他东西的实现,它就会变得混乱很快。我从C移植项目++和是新来的Java(而这个项目也让我试图让事情尽可能相同,而得到它的工作),所以任何参考或例子将是巨大的。

Where can I find an implementation of multimap for Java that will work on Android without having to include any other classes etc. The implementations I've found all require other things which require other things and it gets messy quick. I'm porting a project from C++ and am new to java (and this project as well so I'm trying to keep things as identical as possible while getting it working) so any references or examples would be great.

推荐答案

您可以使用地图和列表来创建一个多重映射。假设你想一个整数,类类型T的列表关联使用下列code:

You could use a Map and a List to create a multimap. Say you wanted to associate an integer with a list of class type T. Use the following code:

地图<整数,列表< T>> myMultiMap =新的HashMap<整数,列表< T>>();

这可能会导致混乱,但是,这应该给你你要寻找的。

It could get messy but, this should give you what you're looking for.

另一种方法是使用番石榴库的<一个href="http://guava-libraries.google$c$c.com/svn/trunk/javadoc/com/google/common/collect/Multimap.html">Multimap实现。

Another option is to use the Guava library's Multimap implementations.

这篇关于在Android在Java中如何创建一个Multimap之的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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