in reply to Generating A Hash Value

Though your question has been answered, I have to wonder if this is really Java's hashing algorighm. It seems as though having an arbitrarily long hash key would be unwieldy. Though, if the algorithm is really that simple, I suppose it'd be fast...

thor

Replies are listed 'Best First'.
Re: Re: Generating A Hash Value
by Anonymous Monk on Jul 03, 2003 at 16:03 UTC
    Two things:
    1. You don't have to wonder, you can read it for yourself.
    2. Seondly, and more importantly, the way the hashCode() method works in java allows for objects of any type to serve as hash keys. The original poster asked a question about the implementation of that method for Strings. (also: Perl allows for arbitrarily long hash keys, too, since any strings are hash keys, and strings are arbitrarily long)
    3. Three things: there is no third thing.
      To address your items, point by point:
      1. I could have, but I'm lazy. And laziness is a virtue.
      2. I understand what purpose hashCode() has. However, in perl, hash codes are not of arbitrary length. There is an algorithm described here that describes an algorithm that takes an arbitrary input and produces a 32-bit hash code. A bit slower, I suppose, but keeps you from having to keep track of an arbitrarily large integer for your hash key. So, it's not necessarily the case that one use arbitrarily large hash codes (which is different from arbitrarily large hash keys)
      3. Good, because I don't either...:).
      4. thor