Java List Remove remove(Collection entityList1, Collection entityList2, Comparator comparator)

Here you can find the source of remove(Collection entityList1, Collection entityList2, Comparator comparator)

Description

remove

License

Open Source License

Declaration

public static List remove(Collection entityList1, Collection entityList2, Comparator comparator) 

Method Source Code


//package com.java2s;
/*/*from  ww w  . j  a  v a 2s . c o  m*/
 * Copyright (c) 2007 Agile-Works
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Agile-Works. ("Confidential Information").
 * You shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement you
 * entered into with Agile-Works.
 */

import java.util.*;

public class Main {
    public static List remove(Collection entityList1, Collection entityList2, Comparator comparator) {
        List result = new ArrayList();
        for (Iterator iter1 = entityList1.iterator(); iter1.hasNext();) {
            Object o1 = iter1.next();
            boolean containedOnList2 = false;
            for (Iterator iter2 = entityList2.iterator(); iter2.hasNext();) {
                Object o2 = iter2.next();
                if (comparator.compare(o1, o2) == 0) {
                    containedOnList2 = true;
                    break;
                }
            }

            if (!containedOnList2)
                result.add(o1);
        }
        return result;
    }
}

Related

  1. remove(final List list, final int index, final T defaultValue)
  2. remove(final List list, final T... objects)
  3. remove(List aList, Object anObj)
  4. remove(List models, int start, int count)