Here you can find the source of hash(int aSeed, boolean aBoolean)
Parameter | Description |
---|---|
aSeed | _more_ |
aBoolean | _more_ |
public static int hash(int aSeed, boolean aBoolean)
//package com.java2s; /*//from www . ja va 2s . c o m * $Id: HashCodeUtils.java,v 1.3 2006/05/05 19:19:34 jeffmc Exp $ * * Copyright 1997-2016 Unidata Program Center/University Corporation for * Atmospheric Research, P.O. Box 3000, Boulder, CO 80307, * support@unidata.ucar.edu. * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or (at * your option) any later version. * * This library 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 Lesser * General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ public class Main { /** _more_ */ private static final int fODD_PRIME_NUMBER = 37; /** * booleans. * * @param aSeed _more_ * @param aBoolean _more_ * * @return _more_ */ public static int hash(int aSeed, boolean aBoolean) { return firstTerm(aSeed) + (aBoolean ? 1 : 0); } /** * chars. * * @param aSeed _more_ * @param aChar _more_ * * @return _more_ */ public static int hash(int aSeed, char aChar) { return firstTerm(aSeed) + (int) aChar; } /** * ints. * * @param aSeed _more_ * @param aInt _more_ * * @return _more_ */ public static int hash(int aSeed, int aInt) { /* * Implementation Note * Note that byte and short are handled by this method, through * implicit conversion. */ return firstTerm(aSeed) + aInt; } /** * longs. * * @param aSeed _more_ * @param aLong _more_ * * @return _more_ */ public static int hash(int aSeed, long aLong) { return firstTerm(aSeed) + (int) (aLong ^ (aLong >>> 32)); } /** * floats. * * @param aSeed _more_ * @param aFloat _more_ * * @return _more_ */ public static int hash(int aSeed, float aFloat) { return hash(aSeed, Float.floatToIntBits(aFloat)); } /** * doubles. * * @param aSeed _more_ * @param aDouble _more_ * * @return _more_ */ public static int hash(int aSeed, double aDouble) { return hash(aSeed, Double.doubleToLongBits(aDouble)); } /** * _more_ * * @param aSeed _more_ * * @return _more_ */ private static int firstTerm(int aSeed) { return fODD_PRIME_NUMBER * aSeed; } }