Hot to port entrySet() method from HashMap<Integer,Object> to trove4j?

157 Views Asked by At

I was often iterating over hashmaps by entrySet() method, expecting this is faster. Now I would like to port some of my code to trove's TIntObjectHashMap, but don't see the method to enumerate entries.

Why? How to port?

2

There are 2 best solutions below

0
On

If you want the most speed, you should look at the forEach* methods. They are the most efficient method to iterate. Otherwise, there are iterator methods as well as methods for directly getting the keys in array form which may be the easiest to port to. However, if speed is your primary concern I would recommend the forEach* methods.

0
On

Looks like you want the http://trove4j.sourceforge.net/javadocs/gnu/trove/map/TIntObjectMap.html#iterator() method (the iterator provides access to the current key).