List of utility methods to do List Intersect
Set | intersectionInplace(List 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); |
List | intersectList(List 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>(); ... |
boolean | intersectSortedAscending(List extends Object> l1, List extends Object> 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(); ... |
boolean | isListIntersect(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; |
void | removeIntersection(List 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)); ... |