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

SetintersectionInplace(List> sets)
intersection Inplace
if (sets.isEmpty())
    return Collections.emptySet();
if (sets.size() == 1)
    return sets.get(0);
Collections.sort(sets, sortBySizeReversed);
Set<X> set = sets.remove(sets.size() - 1);
return retainAllAll(set, sets);
ListintersectList(List list1, List list2)
Intersect list.
if (isEmpty(list1) && isEmpty(list2)) {
    return new ArrayList<T>();
if (isEmpty(list1) && !isEmpty(list2)) {
    return new ArrayList<T>();
if (!isEmpty(list1) && isEmpty(list2)) {
    return new ArrayList<T>();
...
booleanintersectSortedAscending(List l1, List l2)
Checks for intersection of lists, exploiting that the lists are (must be!) sorted in ascending order of the hashcodes of their elements.
Iterator<? extends Object> it1 = l1.iterator();
Iterator<? extends Object> it2 = l2.iterator();
if (!it1.hasNext() || !it2.hasNext())
    return false; 
Object o1 = it1.next();
Object o2 = it2.next();
int h1 = o1.hashCode();
int h2 = o2.hashCode();
...
booleanisListIntersect(List list1, List list2)
is List Intersect
for (int i = 0; i < list1.size(); i++)
    if (list2.contains(list1.get(i)))
        return true;
return false;
voidremoveIntersection(List intervals, List intervalsToRemove)
remove Intersection
List<int[]> newIntervals;
boolean isChanged = true;
while (isChanged) {
    isChanged = false;
    for (int[] intervalToRemove : intervalsToRemove) {
        for (int[] interval : intervals) {
            if (intersect(intervalToRemove, interval)) {
                newIntervals = getNonIntersection(interval, getIntersection(interval, intervalToRemove));
...