Methods Summary |
---|
public static void | addArray(java.util.Set set, T[] array)
for( final T item : array )
{
set.add( item );
}
|
public static java.util.HashSet | copySet(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 T | getSingleton(java.util.Set s)
if ( s.size() != 1 )
{
throw new IllegalArgumentException( s.toString() );
}
return( s.iterator().next() );
|
public static java.util.Set | intersectSets(java.util.Set set1, java.util.Set set2)Return a new Set of all items in both set1 and set2.
final Set<T> result = newSet( set1 );
result.retainAll( set2 );
return( result );
|
public static java.util.Set | newNotCommonSet(java.util.Set set1, java.util.Set set2)Return a new Set of all items not common to both sets.
final Set<T> result = newSet( set1, set2 );
final Set<T> common = intersectSets( set1, set2);
result.removeAll( common );
return( result );
|
public static java.util.Set | newSet(java.util.Set s1, java.util.Set s2)
final Set<T> both = new HashSet<T>();
both.addAll( s1 );
both.addAll( s2 );
return both;
|
public static java.util.Set | newSet(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.Set | newSet(java.util.Collection c)
final HashSet<T> set = new HashSet<T>();
set.addAll( c );
return( set );
|
public static java.util.Set | newSet(T item)Create a new Set with one member.
final Set<T> set = new HashSet<T>();
set.add( item );
return( set );
|
public static java.util.Set | newSet(T m1, T m2)
final HashSet<T> set = new HashSet<T>();
set.add( m1 );
set.add( m2 );
return( set );
|
public static java.util.Set | newSet(T m1, T m2, T m3, T m4)
final HashSet<T> set = new HashSet<T>();
set.add( m1 );
set.add( m2 );
set.add( m3 );
set.add( m4 );
return( set );
|
public static java.util.Set | newSet(T[] objects)Create a new Set containing all array elements.
return( newSet( objects, 0, objects.length ) );
|
public static java.util.Set | newSingletonSet(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.Set | newStringSet(java.lang.String args)
return newUnmodifiableSet( args );
|
public static java.util.Set | newStringSet(java.lang.Object args)
final Set<String> set = new HashSet<String>();
for( final Object o : args )
{
set.add( o == null ? null : "" + o );
}
return set;
|
public static java.util.Set | newUnmodifiableSet(T args)
final Set<T> set = new HashSet<T>();
for( final T s : args )
{
set.add( s );
}
return set;
|
public static java.util.Set | newUnmodifiableStringSet(java.lang.String args)
return Collections.unmodifiableSet( newStringSet( args ) );
|
public static java.util.Set | removeSet(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.String[] | toSortedStringArray(java.util.Set s)
final String[] strings = toStringArray( s );
Arrays.sort( strings );
return( strings );
|
public static java.lang.String[] | toStringArray(java.util.Set s)Convert a Set to a String[]
final String[] strings = new String[ s.size() ];
int i = 0;
for( final Object o : s )
{
strings[ i ] = "" + o;
++i;
}
return( strings );
|