List of utility methods to do List Intersect
void | intersect(List lst1, List lst2) intersect for (int i = 0; i < lst1.size(); i++) { Object obj1 = lst1.get(i); if (!lst2.contains(obj1)) lst1.remove(i--); |
List | intersect(List extends T> list1, List extends T> list2) This method returns a new ArrayList which is the intersection of the two List parameters, based on Object#equals(Object) equality of their elements. if (list1 == null || list1.isEmpty() || list2 == null || list2.isEmpty()) { return Collections.emptyList(); List<T> result = new ArrayList<T>(); result.addAll(list1); result.retainAll(list2); return result; |
List | intersect(List Returns a set intersection of the given lists. List<E> results = create(); boolean seeded = false; for (List<E> list : lists) { if (list != null) { if (seeded) { results.retainAll(list); } else { results.addAll(list); ... |
List | intersect(List intersect final List<T> theResults = new ArrayList<T>(0); if (in1 == null || in2 == null || in1.isEmpty() || in2.isEmpty()) { return theResults; for (final T anObject : in1) { if (anObject == null && in2.contains(null)) { theResults.add(anObject); } else if (anObject != null && in2.contains(anObject)) { ... |
boolean | intersect(Set> a, List> b) intersect return intersect(a, (Iterable<?>) b);
|
List | intersect2orderedList(List Computes the intersection of 2 integer ordered lists. if (s1.size() > s2.size()) return intersect2orderedList(s2, s1); List<Integer> res = new ArrayList<Integer>(); int pos1 = 0, pos2 = 0; while (pos1 < s1.size() && pos2 < s2.size()) { if (s1.get(pos1).equals(s2.get(pos2))) { res.add(s1.get(pos1)); pos1++; ... |
void | intersectAll(final List Intersects the two given arrays in bag logic. int index1 = 0; int index2 = 0; while (true) { if (index1 >= a.length || index2 >= b.length) { break; } else { final T candidate1 = a[index1]; final T candidate2 = b[index2]; ... |
List | intersectDate(List intersect Date SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); List<Date> listDate = new ArrayList<Date>(); for (Date wDate : oDate) { for (Date iDate : tDate) { String strWDate = sdf.format(wDate).toString(); String strIDate = sdf.format(iDate).toString(); if (strWDate.equals(strIDate)) { listDate.add(wDate); ... |
List | intersection(final List list1, final List list2) Returns a new list containing all elements that are contained in both given lists. final ArrayList result = new ArrayList(); final Iterator iterator = list2.iterator(); while (iterator.hasNext()) { final Object o = iterator.next(); if (list1.contains(o)) result.add(o); return result; ... |
List | intersection(final List list1, final List list2) Returns a new list containing all elements that are contained in both given lists. final ArrayList result = new ArrayList(); final Iterator iterator = list2.iterator(); while (iterator.hasNext()) { final Object o = iterator.next(); if (list1.contains(o)) { result.add(o); return result; |