List of utility methods to do Collection Compare
boolean | compareExactOrder(Collection> c1, Collection> c2) compare Exact Order if (c1.size() != c2.size()) return false; Iterator<?> i1 = c1.iterator(); Iterator<?> i2 = c2.iterator(); while (i1.hasNext()) if (i1.next() != i2.next()) return false; return true; ... |
boolean | compareRef(final Collection left, final Collection right) compare Ref if (left == right) { return true; return false; |
boolean | compareSet(Collection s1, Collection s2) Compares two sets of Objects. if (s1 == null) { return s2 == null; } else if (s2 == null) { return false; if (s1.size() != s2.size()) { return false; HashSet set2 = new HashSet(s2); Iterator i = s1.iterator(); while (i.hasNext()) { Object obj = i.next(); boolean found = false; Iterator j = set2.iterator(); while (j.hasNext()) { if (obj.equals(j.next())) { j.remove(); found = true; break; if (!found) return false; return true; |
int | compareTo(Collection compare To if (o1.size() < o2.size()) return -1; if (o1.size() > o2.size()) return 1; Iterator<E> it1 = o1.iterator(); Iterator<E> it2 = o2.iterator(); for (; it1.hasNext() && it2.hasNext();) { E first = it1.next(); ... |
int | compareTo(Collection compare To int c = a.size() - b.size(); if (c != 0) return c; Iterator<T> ia = a.iterator(); Iterator<T> ib = b.iterator(); while (ia.hasNext()) { c = ia.next().compareTo(ib.next()); if (c != 0) ... |