This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
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


Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
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: 44449
    
  34
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: 44449
    
  34
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: writing efficient hashcode implementation
 
It's not a secret anymore!