问题描述
从 ,我发现Colt的 OpenIntIntHashMap 和Trove的 TIntIntHashMap 比Java内置的 HashMap 或Guava的 HashMultimap 。
做Colt的 OpenIntIntHashMap 或Trove的 TIntIntHashMap 允许具有多个值的键,如 HashMultimap ?如果不是实现可以实现Colt或Trove的性能和内存效率的 HashMultimap 的好方法?
注意:我已经测试过Guava的 HashMultimap ,但是它的性能和内存效率对我来说似乎很差。 解决方案
Multimaps.newSetMultimap(
TDecorators.wrap(new TIntObjectHashMap< Collection< Integer>>()),
new Supplier< Set<整数>>(){
public Set< Integer> get(){
return TDecorators.wrap(new TIntHashSet());
}
});
From here, I found that Colt's OpenIntIntHashMap and Trove's TIntIntHashMap give better performance and memory uses than Java's built in HashMap or Guava's HashMultimap.
Do Colt's OpenIntIntHashMap or Trove's TIntIntHashMap allow keys with multiple values, as with HashMultimap? If not what is a nice way to implement a HashMultimap that can achieve Colt's or Trove's performance and memory efficiency?
Note: I have tested Guava's HashMultimap, but its performance and memory efficiency seems poor to me.
Multimaps.newSetMultimap( TDecorators.wrap(new TIntObjectHashMap<Collection<Integer>>()), new Supplier<Set<Integer>>() { public Set<Integer> get() { return TDecorators.wrap(new TIntHashSet()); } });
这篇关于Java Hash Multi Map(具有多个值的键)实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!