Java Hash Code Calculate hashCode(int num)

Here you can find the source of hashCode(int num)

Description

Hash the specified int using implementation proposed in Josh Bloch's "Effective Java".

License

Open Source License

Parameter

Parameter Description
num The int to be hashed.

Return

Returns the hash code of the int.

Declaration

public static int hashCode(int num) 

Method Source Code

//package com.java2s;
/*//from w  w w .j av  a 2 s  .c o m
 * This file is part of the Raster Storage Archive (RSA).
 *
 * The RSA is free software: you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * The RSA is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * the RSA.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Copyright 2013 CRCSI - Cooperative Research Centre for Spatial Information
 * http://www.crcsi.com.au/
 */

public class Main {
    /**
     * Hash code used in hashing int
     */
    public static int HASH_CODE = 123456789;

    /**
     * Hash the specified int using implementation proposed in Josh Bloch's
     * "Effective Java". Refer to
     * http://stackoverflow.com/questions/113511/hash-code-implementation
     * 
     * @param num
     *            The int to be hashed.
     * @return Returns the hash code of the int.
     */
    public static int hashCode(int num) {
        return 37 * HASH_CODE + num;
    }
}

Related

  1. hashCode(final Object... array)
  2. hashCode(float value)
  3. hashCode(int base, int multiplier, boolean fastArrays, Object... relevantValues)
  4. hashCode(int currentHashCodeValue, boolean b)
  5. hashCode(int mul, Object obj)
  6. hashCode(int previous, boolean x)
  7. hashCode(int result, Object obj)
  8. hashCode(int val)
  9. hashCode(int[] a)