Example usage for java.util Arrays hashCode

List of usage examples for java.util Arrays hashCode

Introduction

In this page you can find the example usage for java.util Arrays hashCode.

Prototype

public static int hashCode(Object a[]) 

Source Link

Document

Returns a hash code based on the contents of the specified array.

Usage

From source file:Main.java

public static int hash(Object... values) {
    return Arrays.hashCode(values);
}

From source file:Main.java

/**
 * Get the hashcode for a bitmap.// w ww.ja v  a  2s.  com
 */
private static String hashBitmap(Bitmap bmp) {
    int[] allpixels = new int[bmp.getHeight() * bmp.getWidth()];
    bmp.getPixels(allpixels, 0, bmp.getWidth(), 0, 0, bmp.getWidth(), bmp.getHeight());
    return Integer.toHexString(Arrays.hashCode(allpixels));
}

From source file:Main.java

public static int hashCode(@Nullable Object... objects) {
    return Arrays.hashCode(objects);
}

From source file:org.openlegacy.terminal.utils.TerminalEqualsHashcodeUtil.java

public static int snapshotHashcode(TerminalSnapshot terminalSnapshot) {
    return Arrays.hashCode(terminalSnapshot.getRows().toArray())
            + terminalSnapshot.getSnapshotType().hashCode();
}

From source file:org.openlegacy.terminal.utils.TerminalEqualsHashcodeUtil.java

public static int rowHashCode(TerminalRow row) {
    return Arrays.hashCode(row.getFields().toArray());
}

From source file:Main.java

public static int hashCode(Object target) {
    if (target == null)
        return 0;
    final int prime = 31;
    int result = 1;

    Class<?> current = target.getClass();
    do {//from   w  w w.  ja  v  a  2s  . co m
        for (Field f : current.getDeclaredFields()) {
            if (Modifier.isStatic(f.getModifiers()) || Modifier.isTransient(f.getModifiers())
                    || f.isSynthetic()) {
                continue;
            }

            Object self;
            try {
                f.setAccessible(true);
                self = f.get(target);
            } catch (IllegalAccessException e) {
                throw new IllegalStateException(e);
            }
            if (self == null) {
                result = prime * result + 0;
            } else if (self.getClass().isArray()) {
                if (self.getClass().equals(boolean[].class)) {
                    result = prime * result + Arrays.hashCode((boolean[]) self);
                } else if (self.getClass().equals(char[].class)) {
                    result = prime * result + Arrays.hashCode((char[]) self);
                } else if (self.getClass().equals(byte[].class)) {
                    result = prime * result + Arrays.hashCode((byte[]) self);
                } else if (self.getClass().equals(short[].class)) {
                    result = prime * result + Arrays.hashCode((short[]) self);
                } else if (self.getClass().equals(int[].class)) {
                    result = prime * result + Arrays.hashCode((int[]) self);
                } else if (self.getClass().equals(long[].class)) {
                    result = prime * result + Arrays.hashCode((long[]) self);
                } else if (self.getClass().equals(float[].class)) {
                    result = prime * result + Arrays.hashCode((float[]) self);
                } else if (self.getClass().equals(double[].class)) {
                    result = prime * result + Arrays.hashCode((double[]) self);
                } else {
                    result = prime * result + Arrays.hashCode((Object[]) self);
                }
            } else {
                result = prime * result + self.hashCode();
            }

            System.out.println(f.getName() + ": " + result);
        }
        current = current.getSuperclass();
    } while (!Object.class.equals(current));

    return result;
}

From source file:VASSAL.tools.HashCode.java

public static final int hash(final boolean[] a) {
    return Arrays.hashCode(a);
}

From source file:com.netflix.zeno.diff.DiffByteArray.java

@Override
public int hashCode() {
    return Arrays.hashCode(bytes);
}

From source file:VASSAL.tools.HashCode.java

public static final int hash(final byte[] a) {
    return Arrays.hashCode(a);
}

From source file:com.opengamma.analytics.math.interpolation.data.Interpolator2DDataBundle.java

@Override
public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + Arrays.hashCode(_xData);
    result = prime * result + Arrays.hashCode(_yData);
    result = prime * result + Arrays.hashCode(_zData);
    return result;
}