Java Collection Subtract subtract(Collection a, Collection b)

Here you can find the source of subtract(Collection a, Collection b)

Description

subtract

License

Open Source License

Declaration

public static Collection subtract(Collection a, Collection b)

    

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;

public class Main {
    public static Collection subtract(Collection a, Collection b)

    {/*from   w  ww  .  j a  v  a  2  s .  c o  m*/

        Collection results = new HashSet();

        for (Iterator i = a.iterator(); i.hasNext();) {

            Object o = i.next();

            if (!(b.contains(o))) {

                results.add(o);

            }

        }

        return results;

    }
}

Related

  1. sub(Collection s, T item)
  2. subCollection(Collection col, int amount)
  3. subCollection(final Collection collection, final int offset, final int limit)
  4. subMap(Map map, Collection keys)
  5. substractBackground( final Map> concentrationToSampleReadings, final Map> concentrationToBackgroundReadings)
  6. subtract(Collection c1, Collection c2)
  7. subtract(Collection a, Collection b)
  8. subtract(Collection c1, Collection c2)
  9. subtract(Collection l1, Collection l2)