Java Hash Multi Map(具有多个值的键)实现

时间:2022-04-17 19:15:16

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.

从这里开始,我发现Colt的OpenIntIntHashMap和Trove的TIntIntHashMap比Java内置的HashMap或Guava的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?

Colt的OpenIntIntHashMap或Trove的TIntIntHashMap是否允许具有多个值的键,与HashMultimap一样?如果没有什么是实现可以实现Colt或Trove性能和内存效率的HashMultimap的好方法?

Note: I have tested Guava's HashMultimap, but its performance and memory efficiency seems poor to me.

注意:我测试了Guava的HashMultimap,但它的性能和内存效率对我来说似乎很差。

1 个解决方案

#1


5  

Multimaps.newSetMultimap(
  TDecorators.wrap(new TIntObjectHashMap<Collection<Integer>>()),
  new Supplier<Set<Integer>>() {
    public Set<Integer> get() {
      return TDecorators.wrap(new TIntHashSet());
    }
  });

#1


5  

Multimaps.newSetMultimap(
  TDecorators.wrap(new TIntObjectHashMap<Collection<Integer>>()),
  new Supplier<Set<Integer>>() {
    public Set<Integer> get() {
      return TDecorators.wrap(new TIntHashSet());
    }
  });