`
younglibin
  • 浏览: 1210911 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

LinkedListMultimap用法

 
阅读更多

public static void main(String[] args) {
		LinkedListMultimap<Integer, String> groupdMap = LinkedListMultimap
				.create();
		for (int i = 0; i < 100; i++) {
			groupdMap.put(i % 10, "value_" + i);
		}
		System.out.println("" + groupdMap.size());
		System.out.println("" + groupdMap.keys().size());
		System.out.println("" + groupdMap.keySet().size());
		System.out.println("" + groupdMap.get(0));
		Iterator<Entry<Integer, String>> it = groupdMap.entries().iterator();
		int count = 0;
		while (it.hasNext()) {
			it.next();
			System.out.println(count);
			count++;
		}
	}

 

100
100
10
[value_0, value_10, value_20, value_30, value_40, value_50, value_60, value_70, value_80, value_90]

 

 

Iterator<Entry<Integer, Collection<String>>> it2 = groupdMap.asMap()
				.entrySet().iterator();

		int count2 = 0;
		while (it2.hasNext()) {
			it2.next();
			System.out.println(count2);
			count2++;
		}

 

0
1
2
3
4
5
6
7
8
9

 

api:http://tool.oschina.net/apidocs/apidoc?api=guava

 

mvn:

mvn:
<dependency>
<groupId>com.google.collections</groupId>
<artifactId>google-collections</artifactId>
<version>1.0</version>
<type>jar</type>
</dependency>

 

jar包 见附件:

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics