Java Collection Difference leftDifference(final Collection c1, final Collection c2)

Here you can find the source of leftDifference(final Collection c1, final Collection c2)

Description

left Difference

License

Open Source License

Declaration

public static Collection leftDifference(final Collection c1,
            final Collection c2) 

Method Source Code

//package com.java2s;
import java.util.ArrayList;
import java.util.Collection;

import java.util.List;

public class Main {
    public static Collection leftDifference(final Collection c1,
            final Collection c2) {
        return rightDifference(c2, c1);
    }/*from  w w  w . j av  a  2s. c o  m*/

    public static Collection rightDifference(final Collection c1,
            final Collection c2) {
        final List result = new ArrayList();
        final Object[] members_c1 = c1.toArray();
        for (int i = 0; i < members_c1.length; i++) {
            if (!c2.contains(members_c1[i])) {
                result.add(members_c1[i]);
            }
        }
        return result;
    }
}

Related

  1. difference(final Collection c1, final Collection c2)
  2. difference(final Collection c1, final Collection c2)
  3. differentNull(Collection collection)
  4. getIntersectAndDiffs(Collection a, Collection b, Comparator comparator)
  5. getSymmetricDifference(final Set firstCollection, final Set secondCollection)