Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2007

Tip: Looking for answers? Try searching our database.

Hash Function

Thread view: 
ahd292 - 04 Jul 2007 21:57 GMT
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.
please help me
thanks
Roedy Green - 04 Jul 2007 22:03 GMT
>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.
see http://mindprod.com/jgloss/hashcode.html
http://mindprod.com/jgloss/hashtable.html
http://mindprod.com/jgloss/hashmap.html

You don't have to write a hashCode function. The one can comes with
String is just fine.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Lew - 07 Jul 2007 16:10 GMT
> http://mindprod.com/jgloss/hashtable.html
> http://mindprod.com/jgloss/hashmap.html

Make sure to read the Javadocs for both these classes.  Practically speaking
there is no need whatsoever any more to use Hashtable when you can make a
Collections.synchronizedMap() call on the HashMap of interest; the latter is
safer, too.

Signature

Lew

Roedy Green - 07 Jul 2007 16:22 GMT
>> http://mindprod.com/jgloss/hashtable.html
>> http://mindprod.com/jgloss/hashmap.html
[quoted text clipped - 3 lines]
>Collections.synchronizedMap() call on the HashMap of interest; the latter is
>safer, too.

The reason I send people to read about Hashtables too is that I wrote
that essay before HashMaps existed.  It contains a some under the mood
information about how hashing works.  I did not repeat it in the
HashMap entry.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Bjorn Borud - 05 Jul 2007 10:15 GMT
[ahd292 <ahd.arman@gmail.com>]
| 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.