Java List Difference getLeftDiff(List list1, List list2)

Here you can find the source of getLeftDiff(List list1, List list2)

Description

get Left Diff

License

Apache License

Declaration

public static <T> List<T> getLeftDiff(List<T> list1, List<T> list2) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.*;

public class Main {

    public static <T> List<T> getLeftDiff(List<T> list1, List<T> list2) {
        if (isEmpty(list2)) {
            return list1;
        }/*from w ww.  j  a v a2s  .c o m*/
        List<T> list = new ArrayList<T>();
        if (isNotEmpty(list1)) {
            for (T o : list1) {
                if (!list2.contains(o)) {
                    list.add(o);
                }
            }
        }
        return list;
    }

    public static boolean isEmpty(Map<?, ?> map) {
        return !isNotEmpty(map);
    }

    public static boolean isEmpty(Collection<?> collection) {
        return !isNotEmpty(collection);
    }

    public static boolean isNotEmpty(Map<?, ?> map) {
        return map != null && map.size() > 0;
    }

    public static boolean isNotEmpty(Collection<?> collection) {
        return collection != null && collection.size() > 0;
    }
}

Related

  1. extractDifference(List l1, List l2, List in1not2, List in2not1, List inBothFrom1, List inBothFrom2, Comparator c)
  2. formatDifferentFileNames(List results)
  3. getDiffentElement(List minList, List maxList)
  4. getDifference(List bigger, List smaller)
  5. getDiffInfo(List infoList)
  6. getListsDiffFormatted(List list0, List list1)
  7. getScoreSeriesByMinMaxAndDiff(List percentClaimedHistory)
  8. hasRemoval(List differences, String path)
  9. maxDiffBetweenCompressedWayNodes(final List wayNodeOffsets)