Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import java.util.Set;

public class Main {
    /**
     * 
     * @param c1
     * @param s1
     * @return c1 - s1
     * 
     */
    public static <T> List<T> minius(Collection<T> c1, Collection<T> s1) {

        if (c1 == null) {
            return Collections.emptyList();
        }

        if (s1 == null || s1.size() == 0) {
            return new ArrayList<T>(c1);
        }
        List<T> list = new ArrayList<T>();
        for (T t : c1) {
            if (!s1.contains(t)) {
                list.add(t);
            }
        }
        return list;
    }

    public static <T> List<T> minius(Collection<T> c1, Set<T> s1) {

        if (c1 == null) {
            return Collections.emptyList();
        }

        if (s1 == null || s1.size() == 0) {
            return new ArrayList<T>(c1);
        }
        List<T> list = new ArrayList<T>();
        for (T t : c1) {
            if (!s1.contains(t)) {
                list.add(t);
            }
        }
        return list;
    }
}