• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

writing efficient hashcode implementation

 
anish jain
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to write an efficient hashcode implementation so that tha hashcodes are uniformly distributed?
 
Campbell Ritchie
Sheriff
Pie
Posts: 49382
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 )
 
Campbell Ritchie
Sheriff
Pie
Posts: 49382
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic