Java Collection First intersect(Collection firstSet, Collection secondSet)

Here you can find the source of intersect(Collection firstSet, Collection secondSet)

Description

intersect

License

BSD License

Declaration

public static Collection intersect(Collection firstSet, Collection secondSet) 

Method Source Code


//package com.java2s;
/*L/*from  w  ww. j  a v a 2  s  . co  m*/
 *  Copyright Ekagra Software Technologies Ltd.
 *  Copyright SAIC, SAIC-Frederick
 *
 *  Distributed under the OSI-approved BSD 3-Clause License.
 *  See http://ncip.github.com/common-security-module/LICENSE.txt for details.
 */

import java.util.*;

public class Main {
    public static Collection intersect(Collection firstSet, Collection secondSet) {
        ArrayList result = new ArrayList();
        Iterator it = firstSet.iterator();
        while (it.hasNext()) {
            Object oj = it.next();
            if (secondSet.contains(oj)) {
                result.add(oj);
            }
        }
        return result;
    }
}

Related

  1. getFirstNonNull(Collection c)
  2. getFirstNotNullValue(final Collection collection)
  3. getFirstOrNull(final Collection collection)
  4. getFirstSortedItem( Collection items, T defaultValue)
  5. getUnionSize(Collection firstCollection, Collection secondCollection)
  6. nullSafeFirstElement(Collection collection)
  7. removeFirst(Collection collection, int numToRemove)
  8. removeFirst(Collection c)
  9. sub(Collection coll, int first, int size)