Java Collection Subtract subtract(Collection a, Collection b)

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

Description

subtract

License

BSD License

Declaration

public static List<Integer> subtract(Collection<Integer> a, Collection<Integer> b) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright SemanticBits, Northwestern University and Akaza Research
 * //w  w  w.jav a 2s. c om
 * Distributed under the OSI-approved BSD 3-Clause License.
 * See http://ncip.github.com/caaers/LICENSE.txt for details.
 ******************************************************************************/

import java.util.*;

public class Main {
    public static List<Integer> subtract(Collection<Integer> a, Collection<Integer> b) {
        Set<Integer> y = new HashSet<Integer>(b);
        Set<Integer> z = new HashSet<Integer>();
        for (Integer i : a) {
            if (y.add(i))
                z.add(i);
        }
        return new ArrayList(z);
    }
}

Related

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