32-bit HashCodes

April 18, 2006

"Hashing is a refinement of the simple idea that searching can be made more efficient if one can quickly narrow one's search by locating a subset of items to search. Each item is characterized by a key, a part of the item which uniquely identifies it; such as an employee-number. Hashing creates a subset of items to search by computing from the key a characteristic value, called the hash, and then groups items with the same hash; the group is called a bin." [1]

Now the problem … in Java2 the Hash Codes are computed as signed integers (32 bit). What happens if in an Hash Map we would like to have more than 2exp(32) keys? The Hash algorithm will fail doing a linear search avoiding all its benefits and performances. The problem could be a little minimized if the Hash Codes are represented as unsigned long (64 bit). Conceptually hash values from any class should be uniformly distributed across the largest integer domain available in the language. In Java this is long, which is specified as 64 bits.

Ref. 1 – http://www.serve.net/buz/hash.adt/java.000.html

Entry Filed under: Java2 & J2EE. .

1 Comment Add your own

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Archives

Feeds