Source Code : Set union and intersection

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Set union and intersection

        

/* *****************************************************************************
 * SetUils.java
 * ****************************************************************************/

/* J_LZ_COPYRIGHT_BEGIN *******************************************************
* Copyright 2001-2004 Laszlo Systems, Inc.  All Rights Reserved.              *
* Use is subject to license terms.                                            *
* J_LZ_COPYRIGHT_END *********************************************************/

import java.util.*;

/**
 * A utility class containing set utility functions.
 *
 * @author Oliver Steele
 */
public abstract class SetUtils {
    public static boolean containsAny(Set a, Set b) {
        for (Iterator iter = b.iterator(); iter.hasNext(); ) {
            if (a.contains(iter.next())) {
                return true;
            }
        }
        return false;
    }

    public static Set intersection(Set a, Set b) {
        Set c = new HashSet();
        for (Iterator iter = b.iterator(); iter.hasNext(); ) {
            Object e = iter.next();
            if (a.contains(e)) {
                c.add(e);
            }
        }
        return c;
    }
}

   
    
    
    
    
    
    
    
  

Thank with us