unikl.disco.misc
Class SetUtils

java.lang.Object
  extended by unikl.disco.misc.SetUtils

public class SetUtils
extends java.lang.Object

A tiny collection of convenience methods useful in dealing with sets but not provided directly by Sun's set classes.

Author:
Frank A. Zdarsky

Constructor Summary
SetUtils()
           
 
Method Summary
static java.util.Map createMap(java.util.Set set, java.lang.Object value)
          Creates a map containing each element of the Set set as key and the Object value as corresponding value.
static java.util.Set getDifference(java.util.Set s1, java.util.Set s2)
          Returns the set difference between the set s1 and the set s2.
static java.util.Set getIntersection(java.util.List sets)
          Returns the intersection of all sets contained in the list sets.
static java.util.Set getIntersection(java.util.Set s1, java.util.Set s2)
          Returns the intersection of set s1 and set s2.
static java.util.Set getUnion(java.util.List sets)
          Returns the union of all sets contained in the list sets.
static java.util.Set getUnion(java.util.Set s1, java.util.Set s2)
          Returns the union of set s1 and set s2.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SetUtils

public SetUtils()
Method Detail

getDifference

public static java.util.Set getDifference(java.util.Set s1,
                                          java.util.Set s2)
Returns the set difference between the set s1 and the set s2.

Parameters:
s1 -
s2 -
Returns:
the difference set

getIntersection

public static java.util.Set getIntersection(java.util.Set s1,
                                            java.util.Set s2)
Returns the intersection of set s1 and set s2.

Parameters:
s1 - a set
s2 - another set
Returns:
the intersection set

getIntersection

public static java.util.Set getIntersection(java.util.List sets)
Returns the intersection of all sets contained in the list sets.

Parameters:
sets - a list of sets
Returns:
the intersection of all sets

getUnion

public static java.util.Set getUnion(java.util.Set s1,
                                     java.util.Set s2)
Returns the union of set s1 and set s2.

Parameters:
s1 - a set
s2 - another set
Returns:
the union set

getUnion

public static java.util.Set getUnion(java.util.List sets)
Returns the union of all sets contained in the list sets.

Parameters:
sets - a list of sets
Returns:
the union of all sets

createMap

public static java.util.Map createMap(java.util.Set set,
                                      java.lang.Object value)
Creates a map containing each element of the Set set as key and the Object value as corresponding value.

Parameters:
set - the set whose elements will be the keys of entries in the map
value - the value of each of the map's entries
Returns:
a map