org.jscience.util
Class CollectionUtils

java.lang.Object
  extended by org.jscience.util.CollectionUtils

public class CollectionUtils
extends java.lang.Object

utility class for calculations on sets


Method Summary
static
<T> java.util.List<T>
asList(java.util.Collection<T> col)
          convenience method to display a collection in a JList for example
static
<T> java.util.Set<? extends T>
difference(java.util.Set<? extends T> set1, java.util.Set<? extends T> set2)
          returns a set that contains all elements from set1 that are not in set2
static
<T> void
filter(java.util.Collection<T> col, Filter<T> filter)
          filters all objects out of the given set that are not accepted by the filter
static
<T> java.util.HashSet<T>
makeSet(T[] array)
          DOCUMENT ME!
static
<T> java.util.HashSet<T>
makeSet(T[] array, boolean ignoreDuplicates)
          DOCUMENT ME!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

asList

public static <T> java.util.List<T> asList(java.util.Collection<T> col)
convenience method to display a collection in a JList for example

Type Parameters:
T - DOCUMENT ME!
Parameters:
col - DOCUMENT ME!
Returns:
DOCUMENT ME!

filter

public static <T> void filter(java.util.Collection<T> col,
                              Filter<T> filter)
filters all objects out of the given set that are not accepted by the filter

Type Parameters:
T - DOCUMENT ME!
Parameters:
col - DOCUMENT ME!
filter - DOCUMENT ME!

makeSet

public static <T> java.util.HashSet<T> makeSet(T[] array)
                                    throws java.lang.IllegalArgumentException
DOCUMENT ME!

Type Parameters:
T - DOCUMENT ME!
Parameters:
array - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.IllegalArgumentException - if the array contains duplicates

makeSet

public static <T> java.util.HashSet<T> makeSet(T[] array,
                                               boolean ignoreDuplicates)
                                    throws java.lang.IllegalArgumentException
DOCUMENT ME!

Type Parameters:
T - DOCUMENT ME!
Parameters:
array - DOCUMENT ME!
ignoreDuplicates - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.IllegalArgumentException - if the array contains duplicates and ignoreduplicates is true

difference

public static <T> java.util.Set<? extends T> difference(java.util.Set<? extends T> set1,
                                                        java.util.Set<? extends T> set2)
returns a set that contains all elements from set1 that are not in set2

Type Parameters:
T - DOCUMENT ME!
Parameters:
set1 - DOCUMENT ME!
set2 - DOCUMENT ME!
Returns:
DOCUMENT ME!