Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Hash Function

Reply
Thread Tools

Hash Function

 
 
ahd292
Guest
Posts: n/a
 
      07-04-2007
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

 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      07-04-2007
On Wed, 04 Jul 2007 20:57:41 -0000, ahd292 <(E-Mail Removed)>
wrote, quoted or indirectly quoted someone who said :

>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
 
Reply With Quote
 
 
 
 
Bjorn Borud
Guest
Posts: n/a
 
      07-05-2007
[ahd292 <(E-Mail Removed)>]
| 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



 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      07-07-2007
Roedy Green wrote:
> 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.

--
Lew
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      07-07-2007
On Sat, 07 Jul 2007 11:10:38 -0400, Lew <(E-Mail Removed)> wrote,
quoted or indirectly quoted someone who said :

>> 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.


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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
hash of hash of hash of hash in c++ rp C++ 1 11-10-2011 04:45 PM
Hash#select returns an array but Hash#reject returns a hash... Srijayanth Sridhar Ruby 19 07-02-2008 12:49 PM
In 'HashMap.put', "if (e.hash == hash && eq(k, e.key))" ? Red Orchid Java 3 01-30-2006 07:04 PM
write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter komal C++ 6 01-25-2005 11:13 AM
standard library for hash table storage and hash algorithm Pieter Claassen C Programming 1 08-04-2004 03:11 AM



Advertisments