----------------------------------------------------------------------------------
package com.guava;
import java.util.Set;
import com.google.common.collect.TreeMultimap;
/** @category: guava
* TreeMultimap 按照键值排序, 一个键对应对个值
* @author aircoder
*
*/
public class Map {
public static void main(String[] args) {
TreeMultimap<Integer,Integer> map = TreeMultimap.create();
map.put(2, 4);
map.put(1, 2);
map.put(1, 3);
map.put(2, 6);
map.put(2, 4);
map.put(3, 6);
map.put(11, 2);
map.put(21, 6);
map.put(6, 7);
map.remove(3, 6);
map.put(12, 3);
Set<Integer> keys = map.keySet();
for(int key:keys)
{
String result = String.format("%d:", key);
Set<Integer> values = map.get(key);
for(int value:values)
{
result = result+" "+value;
}
System.out.println(result);
}
}
}
----------------------------------------------------------------------------------
分享到:
相关推荐
google-guava-22.0.jar jackson-annotations-2.9.2.jar jackson-core-2.9.2.jar jackson-core-asl-1.9.13.jar jackson-databind-2.9.2.jar jackson-mapper-asl-1.9.13.jar mapstruct-1.2.0.Final.jar spring-plugin-...
guava-19.0-rc2.jar:不可变对象Guava:ImmutableXXX:Collection、List、Set、Map… (jar包下载)
import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; 报错,找不到这些类 解决: 要用guava.jar包 Guava 中文是石榴的意思,该项目是 Google 的一个开源项目,...
Guava-谷歌提供的一组核心Java库,特别使用了Guava Cache JUnit 5-测试框架 怎么跑 生成应用程序,部署它并运行测试。 mvn deploy 运行应用程序 java -jar target/book-library-0.0.1-SNAPSHOT.jar API端点 图书...
主要介绍了 java Map转Object与Object转Map实现代码的相关资料,需要的朋友可以参考下
learn_spring_multi_cache 使用spring cache构建的多级缓存 自由组合切换 guava redis memcache enhance map,充分利用了本地缓存的高效和分布式缓存的共享特性。
A library to develop ...Map
使用j2cache就可以简单的实现这种切换,j2cache实现了Map接口可以更友好的切换旧代码,这对于开发人员来说是透明的。 主要特点 针对K-V缓存提供一种扩展的思路,并且统一缓存的访问接口,开发人员可以在系统中灵活的...
There are lots of functions to manipulate a Map such as in Guava or Apache Commons, and you should be able to re-use them. Additional Map utilities are provided here. Json addr = new Json() { ...
A Cache 类似于 ConcurrentMap,但不完全相同。 最根本的区别是 ConcurrentMap 保留所有添加到它的元素,直到它们被显式删除。 另一方面,缓存通常配置为自动驱逐条目,以限制其内存占用。 在某些情况下, Loading...
流实用程序( , , ): histogram = zip(times, counts).toMap(); 为提供了额外的实用程序: optional(id.length() > 0, id) 字符串在找到一个子字符串: String user = first('@').toEnd().removeFrom(email);...
在编程领域,缓存是不可或缺的一部分,从处理器到应用层,其...实际上,Caffeine与ConcurrentMap在功能上有许多相似之处,都支持并发操作,且数据的存取时间复杂度为O(1)。然而,二者在数据管理策略上存在显著差异:
LeetCode字符串换行 #Build Status #Features 特征 easy-to-use embedded jetty 8 server ...map ...封装过的本地缓存管理器和接口管理器,使用guava wrapped http client to fetch data 封装过的http
数据结构Java 主要数据结构——java中的简单实现如何使用集合:-> JDK(Java集合)-> Guava(谷歌)-> Commons-collections(Apache) 主要抽象数据结构——ADS列表(ArrayList、LinkedList、Vector)栈(FIFO)队列...
在下面,您可以比较使用Gson的LinkedTreeMap加载50,000个事件,将它们转换为LinkedHashMap,guava的ImmutableMap和TinyMap的内存需求,无论对象是否重复使用。有什么缺点吗? 是的。 通过不存储Entry 对象,仅存储...
缺点: 未实现Map接口性能问题:所有方法(读/写)都已同步过于简化的API:仅获取/放入难以测试对Java 8不友好##番石榴缓存来自Google的应用缓存( ) 优点: 战斗测试功能齐全(自加载缓存,刷新策略,统计信息......
Redis主要用于缓存,自定义map、guava的缓存也可以用于简单缓存。 自定义缓存时,注意value要使用SoftReference包装,以便JVM回收 guava缓存:CacheBuilder、LoadingCache 1. 数据结构 1. string 2. list 3. hash 4....
Furthermore, Java’s standard library was lacking a decent support for functional programming primitives (map, filter) but that was easily fixable with libraries such as Guava. This lead me to a ...
使用map reduce方法,对进程进行fork-> search-> reduce以生成结果。 测试用例是基于Guava Cache引擎创建的。 在实际环境中,缓存的内容存储在Memcache中。 这更有效,使用命令“ service memcached restart”清理...