Hash Function

Discussion in 'Java' started by ahd292, Jul 4, 2007.

  1. ahd292

    ahd292 Guest

    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
    ahd292, Jul 4, 2007
    #1
    1. Advertising

  2. ahd292

    Roedy Green Guest

    On Wed, 04 Jul 2007 20:57:41 -0000, ahd292 <>
    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
    Roedy Green, Jul 4, 2007
    #2
    1. Advertising

  3. ahd292

    Bjorn Borud Guest

    [ahd292 <>]
    | 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
    Bjorn Borud, Jul 5, 2007
    #3
  4. ahd292

    Lew Guest

    Lew, Jul 7, 2007
    #4
  5. ahd292

    Roedy Green Guest

    On Sat, 07 Jul 2007 11:10:38 -0400, Lew <> 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
    Roedy Green, Jul 7, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Red Orchid
    Replies:
    3
    Views:
    1,038
  2. Pieter Claassen
    Replies:
    1
    Views:
    1,108
    CBFalconer
    Aug 4, 2004
  3. Bo Peng
    Replies:
    4
    Views:
    786
  4. rp
    Replies:
    1
    Views:
    517
    red floyd
    Nov 10, 2011
  5. Srijayanth Sridhar
    Replies:
    19
    Views:
    612
    David A. Black
    Jul 2, 2008
Loading...

Share This Page