List of utility methods to do Collection Difference
int[] | computeDifferenceIndices(Collection> smallCollection, Collection> bigCollection) Computes the array of element indices which where added to a collection. List<Integer> addedIndices = new ArrayList<>(); int index = 0; for (Iterator<?> ite = bigCollection.iterator(); ite.hasNext(); index++) { if (smallCollection == null || !smallCollection.contains(ite.next())) { if (smallCollection == null) { ite.next(); addedIndices.add(index); ... |
Collection | diff(Collection diff if (c1 == null || c1.size() == 0 || c2 == null || c2.size() == 0) { return c1; Collection<T> difference = new ArrayList<T>(); for (T item : c1) { if (!c2.contains(item)) { difference.add(item); return difference; |
List | diffColls(Collection> oldColl, Collection> newColl) diff Colls List<Object[]> ops = new ArrayList<Object[]>(); for (Object newElt : newColl) { if (!oldColl.contains(newElt)) ops.add(new Object[] { 1, null, newElt }); for (Object oldElt : oldColl) { if (!newColl.contains(oldElt)) ops.add(new Object[] { -1, null, oldElt }); ... |
Collection | difference(Collection difference List<E> differenceCopy = new ArrayList<E>(); differenceCopy.addAll(set1); differenceCopy.removeAll(set2); return differenceCopy; |
Collection | difference(Collection Stores the differences of two collections in a result collection. for (Iterator<K> iterator = collection1.iterator(); iterator.hasNext();) { K item = iterator.next(); if (!collection2.contains(item)) { result.add(item); return result; |
Collection | difference(Collection Difference of two collections return null;
|
Collection | difference(final Collection c1, final Collection c2) difference return union(leftDifference(c1, c2), rightDifference(c1, c2));
|
List | difference(final Collection Returns a such that a exists in c1 but not in c2. if (c1 == null || c1.size() == 0) { return new ArrayList<>(0); if (c2 == null || c2.size() == 0) { return new ArrayList<>(c1); final List<T> difference = new ArrayList<>(); for (final T current : c1) { ... |
Boolean | differentNull(Collection collection) different Null return collection != null;
|
List | getIntersectAndDiffs(Collection extends T> a, Collection extends T> b, Comparator Returns a three-element array of mutable List s:
int aSize = a.size(); List<T> aDiff = new ArrayList<T>(aSize); aDiff.addAll(a); int bSize = b.size(); List<T> bDiff = new ArrayList<T>(bSize); bDiff.addAll(b); if (comparator != null) { Collections.sort(aDiff, comparator); ... |