Java Hash Code Calculate hashCode(long value)

Here you can find the source of hashCode(long value)

Description

Return a hash code of the given long integer value.

License

Open Source License

Parameter

Parameter Description
value A long integer value.

Return

A hash code of the given value.

Declaration

public static int hashCode(long value) 

Method Source Code

//package com.java2s;
/*//from w w w  . j av a2s  .co  m
 * Copyright (c) 2015 NEC Corporation
 * All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this
 * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
 */

public class Main {
    /**
     * Return a hash code of the given long integer value.
     *
     * @param value  A long integer value.
     * @return  A hash code of the given value.
     */
    public static int hashCode(long value) {
        return (int) (value ^ (value >>> Integer.SIZE));
    }

    /**
     * Return a hash code of the given double value.
     *
     * @param value  A double value.
     * @return  A hash code of the given value.
     */
    public static int hashCode(double value) {
        return hashCode(Double.doubleToLongBits(value));
    }
}

Related

  1. hashCode(int[] array)
  2. hashCode(int[][] arrays)
  3. hashCode(Iterable iterable)
  4. hashCode(long a[])
  5. hashCode(long longVal)
  6. hashCode(long x)
  7. hashCode(long[] a, int fromIndex, int toIndex)
  8. hashCode(Object a)
  9. hashCode(Object array)