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.

Paul Bellora
  • 54,340
  • 18
  • 130
  • 181
Arpssss
  • 3,850
  • 6
  • 36
  • 80

1 Answers1

5
Multimaps.newSetMultimap(
  TDecorators.wrap(new TIntObjectHashMap<Collection<Integer>>()),
  new Supplier<Set<Integer>>() {
    public Set<Integer> get() {
      return TDecorators.wrap(new TIntHashSet());
    }
  });
Louis Wasserman
  • 191,574
  • 25
  • 345
  • 413
  • Thanks. But, for using this structure what should I have to do ? Means, is Trove has any .jar file ? – Arpssss Apr 07 '12 at 16:33
  • If you go to the Trove website and go to the "Downloads" section it's pretty straightforward. – Louis Wasserman Apr 07 '12 at 16:36
  • Thanks. Actually, I download trove from http://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. – Arpssss Apr 07 '12 at 17:19
  • 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. – Louis Wasserman Apr 07 '12 at 17:28