Java List Intersect calcIntersection(List a, List b)

Here you can find the source of calcIntersection(List a, List b)

Description

calc Intersection

License

Open Source License

Declaration

public static void calcIntersection(List<Integer> a, List<Integer> b) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.List;

public class Main {
    public static void calcIntersection(List<Integer> a, List<Integer> b) {
        int aBegin = 0;

        int bBegin = 0;

        while (aBegin < a.size()) {

            while (bBegin < b.size() && b.get(bBegin).intValue() < a.get(aBegin).intValue()) {
                bBegin++;//from ww  w  . j  av a 2 s .c o  m
            }

            if (bBegin < b.size() && a.get(aBegin).intValue() == b.get(bBegin).intValue()) {
                aBegin++;
            } else {
                a.remove(aBegin);
            }
        }
    }
}

Related

  1. calculauteIntersection(Set wordList1, Set wordList2)
  2. getIntersection( final List... collectionOfIDLists)
  3. getIntersection(List list1, List list2)
  4. getIntersection(String[] list1, String[] list2)