Here you can find the source of hash(int n)
public static int hash(int n)
//package com.java2s; /*/*from w w w . jav a2 s . c o m*/ Copyright 1995-2013 Esri Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. For additional information, contact: Environmental Systems Research Institute, Inc. Attn: Contracts Dept 380 New York Street Redlands, California, USA 92373 email: contracts@esri.com */ public class Main { public static int hash(int n) { int hash = 5381; hash = ((hash << 5) + hash) + (n & 0xFF); /* hash * 33 + c */ hash = ((hash << 5) + hash) + ((n >> 8) & 0xFF); hash = ((hash << 5) + hash) + ((n >> 16) & 0xFF); hash = ((hash << 5) + hash) + ((n >> 24) & 0xFF); hash &= 0x7FFFFFFF; return hash; } public static int hash(double d) { long bits = Double.doubleToLongBits(d); int hc = (int) (bits ^ (bits >>> 32)); return hash(hc); } public static int hash(int hashIn, int n) { int hash = ((hashIn << 5) + hashIn) + (n & 0xFF); /* hash * 33 + c */ hash = ((hash << 5) + hash) + ((n >> 8) & 0xFF); hash = ((hash << 5) + hash) + ((n >> 16) & 0xFF); hash = ((hash << 5) + hash) + ((n >> 24) & 0xFF); hash &= 0x7FFFFFFF; return hash; } public static int hash(int hash, double d) { long bits = Double.doubleToLongBits(d); int hc = (int) (bits ^ (bits >>> 32)); return hash(hash, hc); } }