Java Collection Intersect intersection(Collection a, Collection b)

Here you can find the source of intersection(Collection a, Collection b)

Description

intersection

License

Open Source License

Declaration

public static Collection intersection(Collection a, Collection b)

    

Method Source Code


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

import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;

public class Main {
    public static Collection intersection(Collection a, Collection b)

    {/*from   ww  w.  j a va  2 s  .  co  m*/

        Collection results = new HashSet();

        for (Iterator i = a.iterator(); i.hasNext();) {

            Object o = i.next();

            if (b.contains(o)) {

                results.add(o);

            }

        }

        return results;

    }
}

Related

  1. intersect(Collection t1, Collection t2)
  2. intersectCollections(Collection collection1, Collection collection2)
  3. intersectingCollections(Collection collection1, Collection collection2)
  4. intersectInto(C into, Collection... from)
  5. intersection( Collection> coll)
  6. intersection(Collection> collectionOfCollections)
  7. intersection(Collection> availableValuesByDescriptor)
  8. intersection(Collection... collections)
  9. intersection(Collection> sets)