/** * Returns a hash code for this {@code Byte}; equal to the result * of invoking {@code intValue()}. * * @return a hash code value for this {@code Byte} */ @Override publicinthashCode() { return Byte.hashCode(value); }
/** * Returns a hash code for a {@code byte} value; compatible with * {@code Byte.hashCode()}. * * @param value the value to hash * @return a hash code value for a {@code byte} value. * @since 1.8 */ publicstaticinthashCode(byte value) { return (int)value; }
/** * Returns a hash code for this {@code Integer}. * * @return a hash code value for this object, equal to the * primitive {@code int} value represented by this * {@code Integer} object. */ @Override publicinthashCode() { return Integer.hashCode(value); }
/** * Returns a hash code for a {@code int} value; compatible with * {@code Integer.hashCode()}. * * @param value the value to hash * @since 1.8 * * @return a hash code value for a {@code int} value. */ publicstaticinthashCode(int value) { return value; }
/** * Returns a hash code for this {@code Character}; equal to the result * of invoking {@code charValue()}. * * @return a hash code value for this {@code Character} */ @Override publicinthashCode() { return Character.hashCode(value); }
/** * Returns a hash code for a {@code char} value; compatible with * {@code Character.hashCode()}. * * @since 1.8 * * @param value The {@code char} for which to return a hash code. * @return a hash code value for a {@code char} value. */ publicstaticinthashCode(char value) { return (int)value; }
/** * Returns a hash code for this {@code Boolean} object. * * @return the integer {@code 1231} if this object represents * {@code true}; returns the integer {@code 1237} if this * object represents {@code false}. */ @Override publicinthashCode() { return Boolean.hashCode(value); }
/** * Returns a hash code for a {@code boolean} value; compatible with * {@code Boolean.hashCode()}. * * @param value the value to hash * @return a hash code value for a {@code boolean} value. * @since 1.8 */ publicstaticinthashCode(boolean value) { return value ? 1231 : 1237; }
/** * Returns a hash code for this string. The hash code for a * {@code String} object is computed as * <blockquote><pre> * s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1] * </pre></blockquote> * using {@code int} arithmetic, where {@code s[i]} is the * <i>i</i>th character of the string, {@code n} is the length of * the string, and {@code ^} indicates exponentiation. * (The hash value of the empty string is zero.) * * @return a hash code value for this object. */ publicinthashCode() { inth= hash; if (h == 0 && value.length > 0) { char val[] = value;
for (inti=0; i < value.length; i++) { h = 31 * h + val[i]; } hash = h; } return h; }
/** * Returns a hash code for this {@code Float} object. The * result is the integer bit representation, exactly as produced * by the method {@link #floatToIntBits(float)}, of the primitive * {@code float} value represented by this {@code Float} * object. * * @return a hash code value for this object. */ @Override publicinthashCode() { return Float.hashCode(value); }
/** * Returns a hash code for a {@code float} value; compatible with * {@code Float.hashCode()}. * * @param value the value to hash * @return a hash code value for a {@code float} value. * @since 1.8 */ publicstaticinthashCode(float value) { return floatToIntBits(value); }
/** * Returns a representation of the specified floating-point value * according to the IEEE 754 floating-point "single format" bit * layout. * * <p>Bit 31 (the bit that is selected by the mask * {@code 0x80000000}) represents the sign of the floating-point * number. * Bits 30-23 (the bits that are selected by the mask * {@code 0x7f800000}) represent the exponent. * Bits 22-0 (the bits that are selected by the mask * {@code 0x007fffff}) represent the significand (sometimes called * the mantissa) of the floating-point number. * * <p>If the argument is positive infinity, the result is * {@code 0x7f800000}. * * <p>If the argument is negative infinity, the result is * {@code 0xff800000}. * * <p>If the argument is NaN, the result is {@code 0x7fc00000}. * * <p>In all cases, the result is an integer that, when given to the * {@link #intBitsToFloat(int)} method, will produce a floating-point * value the same as the argument to {@code floatToIntBits} * (except all NaN values are collapsed to a single * "canonical" NaN value). * * @param value a floating-point number. * @return the bits that represent the floating-point number. */ publicstaticintfloatToIntBits(float value) { intresult= floatToRawIntBits(value); // Check for NaN based on values of bit fields, maximum // exponent and nonzero significand. if ( ((result & FloatConsts.EXP_BIT_MASK) == FloatConsts.EXP_BIT_MASK) && (result & FloatConsts.SIGNIF_BIT_MASK) != 0) result = 0x7fc00000; return result; }