aspose file tools*
The moose likes Java in General and the fly likes writing efficient hashcode implementation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "writing efficient hashcode implementation" Watch "writing efficient hashcode implementation" New topic
Author

writing efficient hashcode implementation

anish jain
Ranch Hand

Joined: Feb 03, 2010
Posts: 129
How to write an efficient hashcode implementation so that tha hashcodes are uniformly distributed?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39436
    
  28
There is a nice example in Effective Java by Joshua Bloch. The same technique is copied into Bruce Eckel's Thinking in Java, which you may be able to find a copy of the 3rd edition on the net (legally).
Ganesh Gowtham
Ranch Hand

Joined: Mar 30, 2005
Posts: 225

Hi

Please check apache commons lang

org.apache.commons.lang.builder.HashCodeBuilder ( to build HashCode ...)

org.apache.commons.lang.builder.EqualsBuilder ( to generate Equsl() based on fields of class )


Thanks, Ganesh Gowtham
http://ganesh.gowtham.googlepages.com
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39436
    
  28
Thank you. Those Apache Commons methods might give effective hash and equals methods, but using such tools does not help one learn the algorithm, I am afraid.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: writing efficient hashcode implementation