Java Hash Code Calculate hashCode(int previous, boolean x)

Here you can find the source of hashCode(int previous, boolean x)

Description

hash Code

License

Apache License

Declaration

public static final int hashCode(int previous, boolean x) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    private static final int PRIME = 1000003;

    public static final int hashCode(int previous, boolean x) {
        return (PRIME * previous) + (x ? 1 : 0);
    }// w w  w.  j  a va 2 s. c o  m

    public static final int hashCode(int previous, int x) {
        return (PRIME * previous) + x;
    }

    public static final int hashCode(int previous, long x) {
        // convert to two ints
        return (PRIME * previous) + (int) (PRIME * (x >>> 32) + (x & 0xFFFFFFFF));
    }

    public static final int hashCode(int previous, float x) {
        return hashCode(previous, (x == 0.0F) ? 0 : Float.floatToIntBits(x));
    }

    public static final int hashCode(int previous, double x) {
        // convert to long
        return hashCode(previous, (x == 0.0) ? 0L : Double.doubleToLongBits(x));
    }

    public static final int hashCode(int previous, Object... x) {
        if (x == null) {
            return PRIME * previous;
        }
        int hc = previous;
        for (int i = 0; i < x.length; i++) {
            hc = (x[i] == null) ? (PRIME * hc) : (PRIME * hc) + x[i].hashCode();
        }
        return hc;
    }
}

Related

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