Java Utililty Methods List Intersect

List of utility methods to do List Intersect

Description

The list of methods to do List Intersect are organized into topic(s).

Method

Listintersection(final List list1, final List list2)
intersection
List<? extends T> smaller = list1;
List<? extends T> larger = list2;
if (list1.size() > list2.size()) {
    smaller = list2;
    larger = list1;
List<T> newSmaller = new ArrayList<T>(smaller);
List<T> result = new ArrayList<T>(smaller.size());
...
Setintersection(List> sets)
intersection
if (sets.isEmpty())
    return Collections.emptySet();
Set<T> accum = new HashSet<>();
accum.addAll(sets.get(0));
for (int i = 1; i < sets.size(); i++) {
    accum = intersection(accum, sets.get(i));
return accum;
...
Listintersection(List list1, List list2)
intersection
list1.retainAll(list2);
return list1;
Listintersection(List list1, List list2)
intersection
if (list1 == null || list2 == null)
    throw new NullPointerException("Not initizalized lists");
List<E> intersection = new LinkedList<E>();
E item;
ListIterator<E> iter = list1.listIterator();
while (iter.hasNext()) {
    item = iter.next();
    if (list2.contains(item)) {
...
ListIntersection(List a, List b)
Intersection
List<Integer> C = new ArrayList<Integer>();
for (Integer i : a) {
    if (b.contains(i)) {
        C.add(i);
return C;
intintersection(List list1, List list2)
intersection
List<String> intersection = new ArrayList<String>();
for (String s : list1) {
    if (list2.contains(s)) {
        intersection.add(s);
return intersection.size();
Listintersection(List arrayOne, List arrayTwo)
intersection
List<T> _intersect = new ArrayList<T>();
for (int i = 0; i < arrayOne.size(); i++) {
    for (int j = 0; j < arrayTwo.size(); j++) {
        if (arrayOne.get(i) == arrayTwo.get(j)) {
            _intersect.add(arrayOne.get(i));
return _intersect;
Listintersection(List listOne, List listTwo)
intersection
ArrayList<T> onlyInOne = new ArrayList<T>(listOne);
onlyInOne.removeAll(listTwo);
ArrayList<T> inBoth = new ArrayList<T>(listOne);
inBoth.removeAll(onlyInOne);
return inBoth;
Listintersection(List set1, List set2)
intersection
List<T> intSet = new ArrayList<T>(set1);
intSet.retainAll(set2);
return intSet;
intintersection_type(List list1, List list2)
This will determine the intersection type of two list Note: undirected 1 vs 2
List<T> tmp = intersection(list1, list2);
if (tmp.size() == list2.size() && tmp.size() == list1.size())
    return 1;
if (tmp.size() < list2.size() && tmp.size() == list1.size())
    return 2;
if (tmp.size() < list1.size() && tmp.size() == list2.size())
    return 5;
if (tmp.size() > 0)
...