Edit: Latest source from later in the thread: http://n4te.com/temp/fast.7z
For kicks I benchmarked some map implementations on Android (G1):
http://chart.apis.google.com/chart?chtt=Get, Android&chs=700x327&chd=t:183105,244140,335693,396728,396728,427246,457763,610351,1617432,1678466,1708984,1739502,1770019,1831054,2014160,2288818,2532959&chds=0,2532959&chxl=0:|FastHashMap, Commons Collections|Hashtable, Java|FastMap, Javolution|HashMap, Java|IdentityMap, Commons Collections|THashMap, Trove|OpenIntObjectHashMap, Cern Cole|HashedMap, Commons Collections|CachingHashMap, JL235|IdentityHashMap, Java|TIntObjectHashMap, Trove|HashMapV2, Doug Lea|CachingFastMap, Nate|FastMap, Nate|FastIdentityMap, Nate|ApacheIntHashMap, Commons Lang|FastIntMap, Nate&cht=bhg&chbh=10&chxt=y&chco=660000|660033|660066|660099|6600CC|6600FF|663300|663333|663366|663399|6633CC|6633FF|666600|666633|666666
http://chart.apis.google.com/chart?chtt=Put, Android&chs=700x327&chd=t:1892090,1922608,2105713,2929687,2929687,2990723,3112793,3234863,3295899,3356933,3417968,3631592,3784179,4058838,4058838,4211426,4547119&chds=0,4547119&chxl=0:|Hashtable, Java|FastHashMap, Commons Collections|IdentityMap, Commons Collections|OpenIntObjectHashMap, Cern Cole|HashedMap, Commons Collections|HashMap, Java|FastMap, Nate|FastIdentityMap, Nate|ApacheIntHashMap, Commons Lang|FastMap, Javolution|FastIntMap, Nate|THashMap, Trove|CachingHashMap, JL235|IdentityHashMap, Java|HashMapV2, Doug Lea|TIntObjectHashMap, Trove|CachingFastMap, Nate&cht=bhg&chbh=10&chxt=y&chco=660000|660033|660066|660099|6600CC|6600FF|663300|663333|663366|663399|6633CC|6633FF|666600|666633|666666
http://chart.apis.google.com/chart?chtt=Total, Android&chs=700x327&chd=t:2288818,2380371,2532959,3295898,3540038,3540039,3692626,3814696,4547119,4730225,5249023,5462645,5462646,5767822,5828857,6744385,6835937&chds=0,6835937&chxl=0:|Hashtable, Java|FastHashMap, Commons Collections|IdentityMap, Commons Collections|OpenIntObjectHashMap, Cern Cole|HashMap, Java|HashedMap, Commons Collections|FastMap, Javolution|THashMap, Trove|CachingHashMap, JL235|FastMap, Nate|FastIdentityMap, Nate|ApacheIntHashMap, Commons Lang|IdentityHashMap, Java|FastIntMap, Nate|HashMapV2, Doug Lea|TIntObjectHashMap, Trove|CachingFastMap, Nate&cht=bhg&chbh=10&chxt=y&chco=660000|660033|660066|660099|6600CC|6600FF|663300|663333|663366|663399|6633CC|6633FF|666600|666633|666666
Android couldn’t run fastutil (too many classes in the JAR!) or alex14n’s FastHashMap (uses 1.6 methods and I’m too lazy to update it).
http://chart.apis.google.com/chart?chtt=Get, Desktop&chs=700x399&chd=t:81973,92695,109297,112064,131087,131433,132471,133509,134546,138350,140426,141809,148035,173284,180201,203722,215135,256295,270822,309214,404677&chds=0,404677&chxl=0:|Object2OpenObjectMap, fastutil|Hashtable, Java|FastHashMap, Commons Collections|THashMap, Trove|HashMapV2, Doug Lea|FastHashMap, alex14n|OpenIntObjectHashMap, Cern Cole|FastMap, Javolution|Int2OpenObjectMap, fastutil|HashedMap, Commons Collections|TIntObjectHashMap, Trove|HashMap, Java|ApacheIntHashMap, Commons Lang|CachingHashMap, JL235|CachingFastMap, Nate|FastMap, Nate|IdentityMap, Commons Collections|FastIdentityMap, Nate|IdentityHashMap, Java|CuckooFastMap, Nate|FastIntMap, Nate&cht=bhg&chbh=10&chxt=y&chco=660000|660033|660066|660099|6600CC|6600FF|663300|663333|663366|663399|6633CC|6633FF|666600|666633|666666
http://chart.apis.google.com/chart?chtt=Put, Desktop&chs=700x399&chd=t:271167,278431,278431,320282,320628,344494,351065,377006,425083,447911,466588,468318,485611,502905,538876,563434,584878,604939,619120,703514,788946&chds=0,788946&chxl=0:|OpenIntObjectHashMap, Cern Cole|FastHashMap, Commons Collections|IdentityHashMap, Java|HashMapV2, Doug Lea|HashMap, Java|THashMap, Trove|CachingHashMap, JL235|Hashtable, Java|CachingFastMap, Nate|CuckooFastMap, Nate|FastHashMap, alex14n|Object2OpenObjectMap, fastutil|HashedMap, Commons Collections|FastMap, Javolution|IdentityMap, Commons Collections|FastMap, Nate|TIntObjectHashMap, Trove|FastIdentityMap, Nate|FastIntMap, Nate|ApacheIntHashMap, Commons Lang|Int2OpenObjectMap, fastutil&cht=bhg&chbh=10&chxt=y&chco=660000|660033|660066|660099|6600CC|6600FF|663300|663333|663366|663399|6633CC|6633FF|666600|666633|666666
http://chart.apis.google.com/chart?chtt=Total, Desktop&chs=700x399&chd=t:360404,412977,419202,432346,461054,475927,482152,550290,561013,566892,618082,670310,672385,723228,728417,812119,819729,820074,852588,969147,974336&chds=0,974336&chxl=0:|FastHashMap, Commons Collections|OpenIntObjectHashMap, Cern Cole|Object2OpenObjectMap, fastutil|HashMapV2, Doug Lea|THashMap, Trove|Hashtable, Java|IdentityHashMap, Java|HashMap, Java|CachingHashMap, JL235|FastHashMap, alex14n|CachingFastMap, Nate|HashedMap, Commons Collections|CuckooFastMap, Nate|FastMap, Javolution|IdentityMap, Commons Collections|FastMap, Nate|TIntObjectHashMap, Trove|FastIdentityMap, Nate|Int2OpenObjectMap, fastutil|ApacheIntHashMap, Commons Lang|FastIntMap, Nate&cht=bhg&chbh=10&chxt=y&chco=660000|660033|660066|660099|6600CC|6600FF|663300|663333|663366|663399|6633CC|6633FF|666600|666633|666666
CachingHashMap is JL235’s class:
http://kenai.com/projects/sf-library/sources/sf/content/SF/src/com/studiofortress/sf/util/collections/CachingHashMap.java?rev=3
I thought it would be faster the second time (same map is used, just clear’ed) since the entry objects are reused, but the caching overhead came out the same as creating new objects. Of course GC is avoided.
The IntHashMap is this class:
http://code.google.com/p/skorpios/source/browse/trunk/skorpios-common/src/com/esotericsoftware/skorpios/util/IntHashMap.java
The FastIdentityHashMap and FastObjectHashMap are the same code as IntHashMap, tweaked a little.
HashMapV2 is from here:
http://mail.openjdk.java.net/pipermail/core-libs-dev/2009-June/001961.html
Would love if you guys can catch me doing anything stupid or have other ideas on fast/efficient maps.