• Post Reply Bookmark Topic Watch Topic
  • New Topic

Hash Function Help  RSS feed

 
ted luton
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have a couple of question in regards to Hash Functions.

What is a Hash Function?

How Can One be Implemented in Java?

Scenario:
- Mapping Booleans to Integer Values
- No Predefined Java Libraries
- Method or Class is Fine

A Verbal Breakdown or a Code Example would Really Help me Here.

Thanks
 
Campbell Ritchie
Marshal
Posts: 56562
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Find a copy of Bruce Eckel's Thinking in Java or Joshua Bloch's Effective Java™. You can find PDFs of the relevant parts (old editions) by Googling. Try here and here. Note these are both old editions.

If you go through those links you can read about hash code methods; in Bloch try page 36. Note that techniques have changed slightly since those books were last updated; most people multiply by 31 not 37 nowadays. There is also a method in the Objects class now, which can do all the hard work for you.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!