get Difference Set - Android java.util

Android examples for java.util:Set

Description

get Difference Set

Demo Code

/* This file is part of the InternalPluginManager.
 *
 * Copyright (C) 2014-2015 Fabian Damken
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version./*  w w  w .  j av a  2  s  .c  om*/
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
//package com.book2s;

import java.util.HashSet;

import java.util.Set;

public class Main {
    /**
     *
     * @param <T>
     *            The type of the set values.
     * @param s0
     *            Set <code>a</code>.
     * @param s1
     *            Set <code>b</code>.
     * @return Returns all value that are present in set a, but also not in set
     *         b.
     */
    public static <T> Set<T> getDifferenceSet(final Set<T> s0,
            final Set<T> s1) {
        assert s0 != null : "S0 cannot be null!";
        assert s1 != null : "S1 cannot be null!";

        final Set<T> result = new HashSet<T>(s0);
        result.removeAll(s1);
        return result;
    }
}

Related Tutorials