/** * Add the hash-code of the given object. * * @param obj Value to get hash-code from. * @return <i>This</i> <tt>HashCode</tt>. */ public HashCode add(final Object obj) { value ^= generate(obj); return this; }
/** * Compares this object with the specified object for order. * * @param obj Value to compare with. * @return A negative integer, zero, or a positive integer as * this object is less than, equal to, or greater than * the specified object. * * @throws ClassCastException Object is not a <tt>HashCode</tt>. */ public int compareTo(final Object obj) throws ClassCastException { HashCode hashCode = (HashCode)obj; return compareTo(hashCode.value); }
/** * Add the hash-code of the given value. * * @param b Value to get hash-code from. * @return <i>This</i> <tt>HashCode</tt>. */ public HashCode add(final boolean b) { value ^= generate(b); return this; }
/** * Add the hash-code of the given value. * * @param f Value to get hash-code from. * @return <i>This</i> <tt>HashCode</tt>. */ public HashCode add(final float f) { value ^= generate(f); return this; }
/** * Add the hash-code of the given value. * * @param f Value to get hash-code from. * @return <i>This</i> <tt>HashCode</tt>. */ public HashCode add(final double f) { value ^= generate(f); return this; }
/** * Generate a shallow hash code for an object array. * * @param array Array to generate hashcode for. * @return Hash code. */ public static int generate(final Object array[]) { return generate(array, false); }
/** * Add the hash-code of the given value. * * @param n Value to get hash-code from. * @return <i>This</i> <tt>HashCode</tt>. */ public HashCode add(final long n) { value ^= generate(n); return this; }
/** * Get the hash code of this object. * * @return Hash code. */ public int hashCode() { return HashCode.generate(elements); }
protected int getHashCode() { return HashCode.generate(dependency); }
protected int getHashCode() { return HashCode.generate(demand); }
protected int getHashCode() { return HashCode.generate(supply); }
/** * Generate a hash code for a double value. * * @param value Double value to generate hash code from. * @return Hash code. */ public static int generate(final double value) { return generate(Double.doubleToLongBits(value)); }
/** * Generate a hash code for an object array. * * <p>Does not handle nested primitive array elements. * * @param array Array to generate hashcode for. * @param deep True to traverse elements which are arrays to * determine the elements hash code. * @return Hash code. */ public static int generate(final Object array[], final boolean deep) { int hashcode = 0; for (int i=0; i<array.length; i++) { if (deep && (array[i] instanceof Object[])) { hashcode ^= generate((Object[])array[i], true); } else { hashcode ^= array[i].hashCode(); } } return hashcode; }
/** * Construct a new VMID. * * @param address The address of the current virtual machine. * @param pid Process identifier. * @param uid Unique identifier. * * @see #getInstance() For getting a VMID instance reference. */ protected VMID(final byte[] address, final PID pid, final UID uid) { this.address = address; this.pid = pid; this.uid = uid; // generate a hashCode for this VMID int code = pid.hashCode(); code ^= uid.hashCode(); code ^= HashCode.generate(address); hashCode = code; }