edu.stanford.nlp.util
Class Sets

java.lang.Object
  extended by edu.stanford.nlp.util.Sets

public class Sets
extends Object

Utilities for sets.

Author:
Roger Levy, Bill MacCartney

Method Summary
static
<E,F> Set<Pair<E,F>>
cross(Set<E> s1, Set<F> s2)
          Returns the set cross product of s1 and s2, as Pairs
static
<E> Set<E>
diff(Set<E> s1, Set<E> s2)
          Returns the difference of sets s1 and s2.
static
<E> Set<E>
intersection(Set<E> s1, Set<E> s2)
          Returns the intersection of sets s1 and s2.
static
<E> boolean
intersects(Set<E> s1, Set<E> s2)
          Returns true if there is at least element that is in both s1 and s2.
static void main(String[] args)
           
static
<E> Set<Set<E>>
powerSet(Set<E> s)
          Returns the powerset (the set of all subsets) of set s.
static
<E> Set<E>
symmetricDiff(Set<E> s1, Set<E> s2)
          Returns the symmetric difference of sets s1 and s2 (i.e.
static
<E> Set<E>
union(Set<E> s1, Set<E> s2)
          Returns the union of sets s1 and s2.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

cross

public static <E,F> Set<Pair<E,F>> cross(Set<E> s1,
                                         Set<F> s2)
Returns the set cross product of s1 and s2, as Pairs


diff

public static <E> Set<E> diff(Set<E> s1,
                              Set<E> s2)
Returns the difference of sets s1 and s2.


symmetricDiff

public static <E> Set<E> symmetricDiff(Set<E> s1,
                                       Set<E> s2)
Returns the symmetric difference of sets s1 and s2 (i.e. all elements that are in only one of the two sets)


union

public static <E> Set<E> union(Set<E> s1,
                               Set<E> s2)
Returns the union of sets s1 and s2.


intersection

public static <E> Set<E> intersection(Set<E> s1,
                                      Set<E> s2)
Returns the intersection of sets s1 and s2.


intersects

public static <E> boolean intersects(Set<E> s1,
                                     Set<E> s2)
Returns true if there is at least element that is in both s1 and s2. Faster than calling intersection(Set,Set) if you don't need the contents of the intersection.


powerSet

public static <E> Set<Set<E>> powerSet(Set<E> s)
Returns the powerset (the set of all subsets) of set s.


main

public static void main(String[] args)


Stanford NLP Group