Java Code Examples for java.util.Arrays.deepHashCode()

The following are Jave code examples for showing how to use deepHashCode() of the java.util.Arrays class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: openjdk-jdk10   File: CompositeDataSupport.java   View Source Code Vote up 5 votes
/**
 * Returns the hash code value for this <code>CompositeDataSupport</code> instance.
 * <p>
 * The hash code of a <code>CompositeDataSupport</code> instance is the sum of the hash codes
 * of all elements of information used in <code>equals</code> comparisons
 * (ie: its <i>composite type</i> and all the item values).
 * <p>
 * This ensures that <code> t1.equals(t2) </code> implies that <code> t1.hashCode()==t2.hashCode() </code>
 * for any two <code>CompositeDataSupport</code> instances <code>t1</code> and <code>t2</code>,
 * as required by the general contract of the method
 * {@link Object#hashCode() Object.hashCode()}.
 * <p>
 * Each item value's hash code is added to the returned hash code.
 * If an item value is an array,
 * its hash code is obtained as if by calling the
 * {@link java.util.Arrays#deepHashCode(Object[]) deepHashCode} method
 * for arrays of object reference types or the appropriate overloading
 * of {@code Arrays.hashCode(e)} for arrays of primitive types.
 *
 * @return the hash code value for this <code>CompositeDataSupport</code> instance
 */
@Override
public int hashCode() {
    int hashcode = compositeType.hashCode();

    for (Object o : contents.values()) {
        if (o instanceof Object[])
            hashcode += Arrays.deepHashCode((Object[]) o);
        else if (o instanceof byte[])
            hashcode += Arrays.hashCode((byte[]) o);
        else if (o instanceof short[])
            hashcode += Arrays.hashCode((short[]) o);
        else if (o instanceof int[])
            hashcode += Arrays.hashCode((int[]) o);
        else if (o instanceof long[])
            hashcode += Arrays.hashCode((long[]) o);
        else if (o instanceof char[])
            hashcode += Arrays.hashCode((char[]) o);
        else if (o instanceof float[])
            hashcode += Arrays.hashCode((float[]) o);
        else if (o instanceof double[])
            hashcode += Arrays.hashCode((double[]) o);
        else if (o instanceof boolean[])
            hashcode += Arrays.hashCode((boolean[]) o);
        else if (o != null)
            hashcode += o.hashCode();
    }

    return hashcode;
}
 
Example 2
Project: VISNode   File: MultiFileInput.java   View Source Code Vote up 5 votes
@Override
public int hashCode() {
    int hash = 7;
    hash = 89 * hash + Arrays.deepHashCode(this.file);
    hash = 89 * hash + this.index;
    return hash;
}
 
Example 3
Project: Meucci   File: TypeDich.java   View Source Code Vote up 5 votes
@Override
public int hashCode() {
    int hash = 5;
    hash = 41 * hash + Objects.hashCode(this.typename);
    hash = 41 * hash + Arrays.deepHashCode(this.params);
    return hash;
}
 
Example 4
Project: OpenJSharp   File: CompositeDataSupport.java   View Source Code Vote up 5 votes
/**
 * Returns the hash code value for this <code>CompositeDataSupport</code> instance.
 * <p>
 * The hash code of a <code>CompositeDataSupport</code> instance is the sum of the hash codes
 * of all elements of information used in <code>equals</code> comparisons
 * (ie: its <i>composite type</i> and all the item values).
 * <p>
 * This ensures that <code> t1.equals(t2) </code> implies that <code> t1.hashCode()==t2.hashCode() </code>
 * for any two <code>CompositeDataSupport</code> instances <code>t1</code> and <code>t2</code>,
 * as required by the general contract of the method
 * {@link Object#hashCode() Object.hashCode()}.
 * <p>
 * Each item value's hash code is added to the returned hash code.
 * If an item value is an array,
 * its hash code is obtained as if by calling the
 * {@link java.util.Arrays#deepHashCode(Object[]) deepHashCode} method
 * for arrays of object reference types or the appropriate overloading
 * of {@code Arrays.hashCode(e)} for arrays of primitive types.
 *
 * @return the hash code value for this <code>CompositeDataSupport</code> instance
 */
@Override
public int hashCode() {
    int hashcode = compositeType.hashCode();

    for (Object o : contents.values()) {
        if (o instanceof Object[])
            hashcode += Arrays.deepHashCode((Object[]) o);
        else if (o instanceof byte[])
            hashcode += Arrays.hashCode((byte[]) o);
        else if (o instanceof short[])
            hashcode += Arrays.hashCode((short[]) o);
        else if (o instanceof int[])
            hashcode += Arrays.hashCode((int[]) o);
        else if (o instanceof long[])
            hashcode += Arrays.hashCode((long[]) o);
        else if (o instanceof char[])
            hashcode += Arrays.hashCode((char[]) o);
        else if (o instanceof float[])
            hashcode += Arrays.hashCode((float[]) o);
        else if (o instanceof double[])
            hashcode += Arrays.hashCode((double[]) o);
        else if (o instanceof boolean[])
            hashcode += Arrays.hashCode((boolean[]) o);
        else if (o != null)
            hashcode += o.hashCode();
    }

    return hashcode;
}
 
Example 5
Project: incubator-netbeans   File: ErrorDescriptionFactory.java   View Source Code Vote up 5 votes
@Override
public int hashCode() {
    int hash = 5;
    hash = 79 * hash + Arrays.deepHashCode(this.keys);
    hash = 79 * hash + (this.handle != null ? this.handle.hashCode() : 0);
    hash = 79 * hash + (this.file != null ? this.file.hashCode() : 0);
    return hash;
}
 
Example 6
Project: incubator-netbeans   File: JShellTool.java   View Source Code Vote up 5 votes
@Override
public int hashCode() {
    int hash = 7;
    hash = 71 * hash + Arrays.deepHashCode(this.cmd);
    hash = 71 * hash + (this.wait ? 1 : 0);
    return hash;
}
 
Example 7
Project: incubator-netbeans   File: RemoteMeasurements.java   View Source Code Vote up 5 votes
@Override
public int hashCode() {
    int hash = 7;
    hash = 79 * hash + this.stackID;
    hash = 79 * hash + (this.category != null ? this.category.hashCode() : 0);
    hash = 79 * hash + Arrays.deepHashCode(this.args);
    return hash;
}
 
Example 8
Project: incubator-netbeans   File: Authentication.java   View Source Code Vote up 5 votes
@Override
public int hashCode() {
    int hash = 5;
    hash = 89 * hash + Arrays.deepHashCode(this.methods);
    hash = 89 * hash + Arrays.hashCode(this.enabled);
    return hash;
}
 
Example 9
Project: openjdk-jdk10   File: JShellTool.java   View Source Code Vote up 5 votes
@Override
public int hashCode() {
    int hash = 7;
    hash = 71 * hash + Arrays.deepHashCode(this.cmd);
    hash = 71 * hash + (this.wait ? 1 : 0);
    return hash;
}
 
Example 10
Project: openjdk-jdk10   File: NodeClass.java   View Source Code Vote up 5 votes
private static int deepHashCode0(Object o) {
    if (o == null) {
        return 0;
    } else if (!o.getClass().isArray()) {
        return o.hashCode();
    } else if (o instanceof Object[]) {
        return Arrays.deepHashCode((Object[]) o);
    } else if (o instanceof byte[]) {
        return Arrays.hashCode((byte[]) o);
    } else if (o instanceof short[]) {
        return Arrays.hashCode((short[]) o);
    } else if (o instanceof int[]) {
        return Arrays.hashCode((int[]) o);
    } else if (o instanceof long[]) {
        return Arrays.hashCode((long[]) o);
    } else if (o instanceof char[]) {
        return Arrays.hashCode((char[]) o);
    } else if (o instanceof float[]) {
        return Arrays.hashCode((float[]) o);
    } else if (o instanceof double[]) {
        return Arrays.hashCode((double[]) o);
    } else if (o instanceof boolean[]) {
        return Arrays.hashCode((boolean[]) o);
    } else {
        throw shouldNotReachHere();
    }
}
 
Example 11
Project: jtk   File: OrbitViewLighting.java   View Source Code Vote up 5 votes
@Override
public int hashCode() {
  int result = Arrays.hashCode(_lightSet);
  result = 31 * result + Arrays.hashCode(_lightTypes);
  result = 31 * result + Arrays.deepHashCode(_ambients);
  result = 31 * result + Arrays.deepHashCode(_speculars);
  result = 31 * result + Arrays.deepHashCode(_diffuses);
  result = 31 * result + Arrays.deepHashCode(_positions);
  return result;
}
 
Example 12
Project: jdk8u-jdk   File: CompositeDataSupport.java   View Source Code Vote up 5 votes
/**
 * Returns the hash code value for this <code>CompositeDataSupport</code> instance.
 * <p>
 * The hash code of a <code>CompositeDataSupport</code> instance is the sum of the hash codes
 * of all elements of information used in <code>equals</code> comparisons
 * (ie: its <i>composite type</i> and all the item values).
 * <p>
 * This ensures that <code> t1.equals(t2) </code> implies that <code> t1.hashCode()==t2.hashCode() </code>
 * for any two <code>CompositeDataSupport</code> instances <code>t1</code> and <code>t2</code>,
 * as required by the general contract of the method
 * {@link Object#hashCode() Object.hashCode()}.
 * <p>
 * Each item value's hash code is added to the returned hash code.
 * If an item value is an array,
 * its hash code is obtained as if by calling the
 * {@link java.util.Arrays#deepHashCode(Object[]) deepHashCode} method
 * for arrays of object reference types or the appropriate overloading
 * of {@code Arrays.hashCode(e)} for arrays of primitive types.
 *
 * @return the hash code value for this <code>CompositeDataSupport</code> instance
 */
@Override
public int hashCode() {
    int hashcode = compositeType.hashCode();

    for (Object o : contents.values()) {
        if (o instanceof Object[])
            hashcode += Arrays.deepHashCode((Object[]) o);
        else if (o instanceof byte[])
            hashcode += Arrays.hashCode((byte[]) o);
        else if (o instanceof short[])
            hashcode += Arrays.hashCode((short[]) o);
        else if (o instanceof int[])
            hashcode += Arrays.hashCode((int[]) o);
        else if (o instanceof long[])
            hashcode += Arrays.hashCode((long[]) o);
        else if (o instanceof char[])
            hashcode += Arrays.hashCode((char[]) o);
        else if (o instanceof float[])
            hashcode += Arrays.hashCode((float[]) o);
        else if (o instanceof double[])
            hashcode += Arrays.hashCode((double[]) o);
        else if (o instanceof boolean[])
            hashcode += Arrays.hashCode((boolean[]) o);
        else if (o != null)
            hashcode += o.hashCode();
    }

    return hashcode;
}
 
Example 13
Project: hadoop   File: FrameworkCounterGroup.java   View Source Code Vote up 4 votes
@Override
public synchronized int hashCode() {
  // need to be deep as counters is an array
  return Arrays.deepHashCode(new Object[]{enumClass, counters, displayName});
}
 
Example 14
Project: athena   File: ClusterMetadata.java   View Source Code Vote up 4 votes
@Override
public int hashCode() {
    return Arrays.deepHashCode(new Object[] {providerId, name, nodes, partitions});
}
 
Example 15
Project: incubator-netbeans   File: ProfilerTreeTable.java   View Source Code Vote up 4 votes
TreePathKey(TreeNode[] _pathToRoot) {
    pathToRoot = _pathToRoot;
    hashCode = Arrays.deepHashCode(pathToRoot);
}
 
Example 16
Project: smile_1.5.0_java7   File: NGram.java   View Source Code Vote up 4 votes
@Override
public int hashCode() {
	return Arrays.deepHashCode(words);
}
 
Example 17
Project: jdk8u-jdk   File: ResultRecord.java   View Source Code Vote up 4 votes
@Override
public int hashCode() {
    return Arrays.deepHashCode(toArray());
}
 
Example 18
Project: SparseBukkitAPI   File: Matrix4f.java   View Source Code Vote up 4 votes
@Override
public int hashCode()
{
	return Arrays.deepHashCode(data);
}
 
Example 19
Project: SparseBukkitAPI   File: Matrix4d.java   View Source Code Vote up 4 votes
@Override
public int hashCode()
{
	return Arrays.deepHashCode(data);
}
 
Example 20
Project: sstore-soft   File: AbstractHasher.java   View Source Code Vote up 2 votes
/**
 * Combine multiple values into a single key and get the hash of that
 * Should be uniformly distributed (or at least good enough for what we need)
 * @param values
 * @return
 */
public int multiValueHash(Object values[]) {
    assert(values.length > 0);
    int combined = 31 * Arrays.deepHashCode(values);
    return (this.hash(combined));
}