It's consistent with standard Java library. I guess it does not matter
much, unless you have a really weird distribution of the input values.

D.

On Mon, Jan 25, 2010 at 4:13 PM, Benson Margulies <bimargul...@gmail.com> wrote:
>  Why do you think they decided that the best hash function for an int
> was the int?
>
>  /**
>   * Returns a hashcode for the specified value.
>   *
>   * @return a hash code value for the specified value.
>   */
>  public static int hash(int value) {
>    return value;
>
>    //return value * 0x278DDE6D; // see
> org.apache.mahout.math.jet.random.engine.DRand
>
>    /*
>    value &= 0x7FFFFFFF; // make it >=0
>    int hashCode = 0;
>    do hashCode = 31*hashCode + value%10;
>    while ((value /= 10) > 0);
>
>    return 28629151*hashCode; // spread even further; h*31^5
>    */
>  }
>

Reply via email to