org.mindswap.pellet.utils
Class SetUtils

java.lang.Object
  extended by org.mindswap.pellet.utils.SetUtils

public class SetUtils
extends java.lang.Object

Utility functions for {#link java.util.Set Set}s.

Author:
Evren Sirin

Field Summary
static java.util.Set EMPTY_SET
           
 
Constructor Summary
SetUtils()
           
 
Method Summary
static java.util.Set binary(java.lang.Object o1, java.lang.Object o2)
           
static java.util.Set create(java.util.Collection coll)
          Creates a set containing all the elements in the collection
static java.util.Set create(java.lang.Object[] elems)
          Creates a list containing all the elements in the array
static java.util.Set difference(java.util.Collection c1, java.util.Collection c2)
          Returns the difference of two sets.
static boolean equals(java.util.Set s1, java.util.Set s2)
          Checks if one set is equal of another one
static java.util.Set intersection(java.util.Collection c1, java.util.Collection c2)
          Returns the intersection of two collections
static boolean intersects(java.util.Collection c1, java.util.Collection c2)
          Checks if two collections have any elemnts in common
static java.util.Set singleton(java.lang.Object o)
           
static boolean subset(java.util.Set sub, java.util.Set sup)
          Checks if one set is subset of another one
static java.util.Set union(java.util.Collection coll)
          Returns the union of all the sets given in a collection.
static java.util.Set union(java.util.Collection c1, java.util.Collection c2)
          Returns the union of two collections
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_SET

public static final java.util.Set EMPTY_SET
Constructor Detail

SetUtils

public SetUtils()
Method Detail

singleton

public static final java.util.Set singleton(java.lang.Object o)

binary

public static final java.util.Set binary(java.lang.Object o1,
                                         java.lang.Object o2)

union

public static java.util.Set union(java.util.Collection coll)
Returns the union of all the sets given in a collection.

Parameters:
coll - A Collection of sets

union

public static java.util.Set union(java.util.Collection c1,
                                  java.util.Collection c2)
Returns the union of two collections

Parameters:
coll - A Collection of sets

intersection

public static java.util.Set intersection(java.util.Collection c1,
                                         java.util.Collection c2)
Returns the intersection of two collections

Parameters:
coll - A Collection of sets

intersects

public static boolean intersects(java.util.Collection c1,
                                 java.util.Collection c2)
Checks if two collections have any elemnts in common


subset

public static boolean subset(java.util.Set sub,
                             java.util.Set sup)
Checks if one set is subset of another one

Parameters:
sub -
sup -
Returns:

equals

public static boolean equals(java.util.Set s1,
                             java.util.Set s2)
Checks if one set is equal of another one

Parameters:
sub -
sup -
Returns:

difference

public static java.util.Set difference(java.util.Collection c1,
                                       java.util.Collection c2)
Returns the difference of two sets. All the elements of second set is removed from the first set

Parameters:
coll - A Collection of sets

create

public static java.util.Set create(java.lang.Object[] elems)
Creates a list containing all the elements in the array

Parameters:
elements -
Returns:

create

public static java.util.Set create(java.util.Collection coll)
Creates a set containing all the elements in the collection

Parameters:
elements -
Returns:


Copyright © 2007-2009 Natalya Keberle. All Rights Reserved.