List of utility methods to do Collection Hash
int | hashCode(Collection c) Computes a hash code over c independent of the underlying Collection implementation. int[] codes = new int[c.size()]; Iterator itr = c.iterator(); int i = 0; while (itr.hasNext()) { codes[i++] = itr.next().hashCode(); Arrays.sort(codes); int prime = 53; ... |
int | hashCode(Collection Method hashCode. int hashCode = 1; Iterator<E> i = collection.iterator(); while (i.hasNext()) { E obj = i.next(); hashCode = (31 * hashCode) + (obj == null ? 0 : obj.hashCode()); return hashCode; |
int | hashCode(Collection Calculates the hash code for a given collection including the order of elements final int prime = 31; int result = 1; if (collection != null) { Iterator<E> iterator = collection.iterator(); while (iterator.hasNext()) { E next = iterator.next(); result = prime * result + (next != null ? next.hashCode() : 0); return result; |
int | hashCodeDeep(Collection collection) Calculates the hashCode of a collection by summing up the hashcodes of all its members. int hashCode = 0; for (Object o : collection) { hashCode += o.hashCode(); return hashCode; |
int | hashCodeUnordered(Collection Calculates the hash code for a given collection not including the order of elements. int result = 1; if (collection != null) { Iterator<E> iterator = collection.iterator(); while (iterator.hasNext()) { E next = iterator.next(); result = result * (next != null ? next.hashCode() : 0); return result; |