[ahd292 <
[email protected]>]
| Hi
| I want to create word dictionary by hash algorithm. But I don't know
| what is the best hash function for this and then how to implement hash
| table in java.
the simple answer is: use java.util.HashSet or java.util.HashMap,
depending on what you need. there's no need to roll your own when
adequate tools exist in the standard library.
if you have special needs that are not adequately catered for in the
standard library, it is quite hard to help you unless you identify
what those needs are.
if you are a student wanting to learn this I would suspect that your
textbook should contain something about hash functions. I can also
recommend "Effective Java" by Josh Bloch, which tells you a bit about
how you override hashCode() (and equals()). you can also locate the
src.jar file, unpack it with a Zip unpacking-utility and have a peek
at the source code of Map and Set types.
-Bjørn