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

voidcalcIntersection(List a, List b)
calc Intersection
int aBegin = 0;
int bBegin = 0;
while (aBegin < a.size()) {
    while (bBegin < b.size() && b.get(bBegin).intValue() < a.get(aBegin).intValue()) {
        bBegin++;
    if (bBegin < b.size() && a.get(aBegin).intValue() == b.get(bBegin).intValue()) {
        aBegin++;
...
booleancalculauteIntersection(Set wordList1, Set wordList2)
calculaute Intersection
Set<String> allWords = populateWordset(wordList1, wordList2);
Iterator<String> wordList = allWords.iterator();
while (wordList.hasNext()) {
    String word = wordList.next();
    boolean freq1 = wordList1.contains(word);
    boolean freq2 = wordList2.contains(word);
    if (freq1 && freq2) {
        return true;
...
ListgetIntersection(final List... collectionOfIDLists)
Returns the common elements of several Integer-Lists.
if (collectionOfIDLists == null || collectionOfIDLists.length == 0) {
    return new ArrayList<Integer>();
final List<List<Integer>> copyListOfIDLists = new ArrayList<List<Integer>>();
for (final List<Integer> list : collectionOfIDLists) {
    copyListOfIDLists.add(new ArrayList<Integer>(list));
final List<Integer> retainedIDs = copyListOfIDLists.get(0);
...
ListgetIntersection(List list1, List list2)
get Intersection
final List<T> result = new ArrayList<T>();
for (final T elem1 : list1)
    if (list2.contains(elem1))
        result.add(elem1);
return result;
String[]getIntersection(String[] list1, String[] list2)
get Intersection
ArrayList intersection = new ArrayList();
for (int i = 0; i < list1.length; i++) {
    if (contains(list1[i], list2))
        intersection.add(list1[i]);
return arrayListToStringArray(intersection);
double[]getIntersectionOfLineAndSegments(double x1, double y1, double x2, double y2, List segmentPoints)
get Intersection Of Line And Segments
return null;
booleanhasIntersection(List list1, List list2)
has Intersection
for (String str : list1)
    if (list2.contains(str))
        return true;
return false;
booleanhasIntersection(Set set, List list)
Check if there is an intersection between the set and the list.
for (T n : set) {
    if (list.contains(n)) {
        return true;
return false;
ListIntersect(List A, List B)
Intersect
if (A == null || B == null)
    return null;
List list = new ArrayList();
for (Iterator i = A.iterator(); i.hasNext();) {
    Object o = i.next();
    if (B.contains(o))
        list.add(o);
return list;
Listintersect(List ls, List ls2)
intersect
List<T> list = new ArrayList(Arrays.asList(new Object[ls.size()]));
Collections.copy(list, ls);
list.retainAll(ls2);
return list;