The list of methods to do Collection Difference are organized into topic(s).
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 c1, Collection c2)
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 });
...
List
difference(final Collection c1, final Collection c2)
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) {
...