FileDocCategorySizeDatePackage
SetUtil.javaAPI DocGlassfish v2 API7541Fri May 04 22:31:06 BST 2007com.sun.appserv.management.util.misc

SetUtil

public final class SetUtil extends Object
deprecated
use GSetUtil

Fields Summary
Constructors Summary
private SetUtil()

		// disallow instantiation
	
Methods Summary
public static voidaddArray(java.util.Set set, T[] array)
Add all items in an array to a set.

		for( int i = 0; i < array.length; ++i )
		{
			set.add( array[ i ] );
		}
	
public static java.util.HashSetcopySet(java.util.Set s1)
Create a new Set containing all members of another. The returned Set is always a HashSet.

		final HashSet<T>	set	= new HashSet<T>();
		
		set.addAll( s1 );
		
		return( set );
	
public static TgetSingleton(java.util.Set s)

		if ( s.size() != 1 )
		{
			throw new IllegalArgumentException( s.toString() );
		}
		return( s.iterator().next() );
	
public static java.util.SetintersectSets(java.util.Set set1, java.util.Set set2)
Return a new Set of all items in both set1 and set2.

		final Set<T>	result	= SetUtil.newSet( set1 );
		result.retainAll( set2 );
		
		return( result );
	
public static java.util.SetnewNotCommonSet(java.util.Set set1, java.util.Set set2)
Return a new Set of all items not common to both sets.

		final Set<T>	result	= SetUtil.newSet( set1, set2 );
		final Set<T>	common	= intersectSets( set1, set2);
		
		result.removeAll( common );
		
		return( result );
	
public static java.util.SetnewSet(java.util.Set s1, java.util.Set s2)
Create a new Set consisting of the contents of two sets.

	    final Set<T>    result  = new HashSet<T>();
	    result.addAll( s1 );
	    result.addAll( s2 );
	    
		return result;
	
public static java.util.SetnewSet(java.util.Set s1, java.util.Set s2, java.util.Set s3)
Create a new Set consisting of the contents of three sets.

	    return newSet( newSet( s1, s2 ), s3 );
	
public static java.util.SetnewSet(java.util.Set s1, java.util.Set s2, java.util.Set s3, java.util.Set s4)
Create a new Set consisting of the contents of four sets.

	    return newSet( newSet( s1, s2 ), newSet( s3, s4) );
	
public static java.util.SetnewSet(T objects)
Create a new Set containing all array elements.

		return( newSet( objects, 0, objects.length ) );
	
public static java.util.SetnewSet(T[] objects, int startIndex, int numItems)
Create a new Set containing all array elements.

		final Set<T>	set	= new HashSet<T>();
		
		for( int i = 0; i < numItems; ++i )
		{
			set.add( objects[ startIndex + i ] );
		}

		return( set );
	
public static java.util.SetnewSet(java.util.Collection c)
Create a new Set with one member.

		final Set<T>	set	= new HashSet<T>();
		
		set.addAll( c );
		
		return( set );
	
public static java.util.SetnewSet(java.util.Set[] sets)
Create a new Set containing all array elements.

		final Set<T>	s	= new HashSet<T>();
		
		for( int i = 0; i < sets.length; ++i )
		{
			s.addAll( sets[ i ] );
		}

		return( s );
	
public static java.util.SetnewSingletonSet(T m1)
Create a new Set with one member. Additional items may be added.

		final Set<T>	set	= new HashSet<T>();
		
		set.add( m1 );
		
		return( set );
	
public static java.util.SetnewUnmodifiableSet(java.lang.String[] objects)

		return GSetUtil.newUnmodifiableStringSet( objects );
	
public static java.util.SetremoveSet(java.util.Set set1, java.util.Set set2)
Return a new Set of all items in set1 not in set2.

		final Set<T>	result	= SetUtil.newSet( set1 );
		result.removeAll( set2 );
		
		return( result );
	
public static java.lang.Object[]toArray(java.util.Set set)
Convert a Set to a String[]

		final Object[]	names	= new Object[ set.size() ];
		set.toArray( names );
		
		return( names );
	
public static java.lang.String[]toStringArray(java.util.Set set)
Convert a Set to a String[]

		final String[]	strings	= new String[ set.size() ];
		
		final Iterator	iter	= set.iterator();
		int	i = 0;
		while ( iter.hasNext() )
		{
			strings[ i ]	= iter.next().toString();
			++i;
		}
		
		return( strings );