Tuesday, 28 April 2009

The Stronghold of Mark Reinhold - Java Collection Classes

Yoda may be a master Jedi, but Mark Reinhold is the primary implementor behind many of the Java collection classes. He has also been involved in the area of NIO high-performance APIs.

A recent interesting class of Mark's I stumbled upon recently (using jdb and typing 'classes' to pull a list of the currently known classes) is the PreHashedMap.java collection class in "package sun.util". This is build on top of java.util.AbstractMap (a skeletal implementation of the Map interface) and has been in orbit since JDK 1.5.

PreHashedMap use memoization to store precomputed hashes. Hashes are computed as the hashCode of an Object, right shifted by a fixed offset and binary AND'ed with a mask. The mask and offset are configured at startup in the constructor of the PreHashedMap.

No comments: