Java Hash Multi Map (key with multiple values) Implementation
Asked Answered
C

1

3

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.

Clam answered 7/4, 2012 at 16:20 Comment(0)
C
5
Multimaps.newSetMultimap(
  TDecorators.wrap(new TIntObjectHashMap<Collection<Integer>>()),
  new Supplier<Set<Integer>>() {
    public Set<Integer> get() {
      return TDecorators.wrap(new TIntHashSet());
    }
  });
Cheesy answered 7/4, 2012 at 16:30 Comment(4)
Thanks. But, for using this structure what should I have to do ? Means, is Trove has any .jar file ?Clam
If you go to the Trove website and go to the "Downloads" section it's pretty straightforward.Cheesy
Thanks. Actually, I download trove from sourceforge.net/projects/trove4j/files/trove/3.0.1. However, when I add trove.jar file in my class path, it gives error that gnu.trove.set.hash.TIntHashSet (and others) are not found. Can you kindly help me, how to use Trove.Clam
The trove-3.0.1.jar file is in the lib folder of the zip file. If adding that to your classpath doesn't help, I can't help you.Cheesy

© 2022 - 2024 — McMap. All rights reserved.