edu.harvard.seas.iis.util.collections
Class CollectionUtils

java.lang.Object
  extended by edu.harvard.seas.iis.util.collections.CollectionUtils

public class CollectionUtils
extends java.lang.Object

Author:
kgajos

Constructor Summary
CollectionUtils()
           
 
Method Summary
static
<K> java.util.Hashtable<K,java.lang.Integer>
getCounts(java.util.Collection<K> c)
          Takes a collection of objects and returns a Hashtable giving counts for how many times each object appears in the collection
static
<K> java.lang.Object[]
getMostCommonElements(java.util.Collection<K> c)
          Returns the most frequent element in a collection.
static
<T> java.util.List<T>
getRandomSubset(java.util.List<T> data, int subsetSize)
           
static
<T> java.util.Vector<T>
intersection(java.util.Collection<T> c1, java.util.Collection<T> c2)
          Returns a vector that contains the intersection of the elements of the two collection passed as input
static
<T> java.util.Vector<T>
union(java.util.Collection<T> c1, java.util.Collection<T> c2)
          Returns a vector that is a sum of the two collection passed as input
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollectionUtils

public CollectionUtils()
Method Detail

union

public static <T> java.util.Vector<T> union(java.util.Collection<T> c1,
                                            java.util.Collection<T> c2)
Returns a vector that is a sum of the two collection passed as input

Parameters:
c1 -
c2 -
Returns:

intersection

public static <T> java.util.Vector<T> intersection(java.util.Collection<T> c1,
                                                   java.util.Collection<T> c2)
Returns a vector that contains the intersection of the elements of the two collection passed as input

Parameters:
c1 -
c2 -
Returns:

getRandomSubset

public static <T> java.util.List<T> getRandomSubset(java.util.List<T> data,
                                                    int subsetSize)

getCounts

public static <K> java.util.Hashtable<K,java.lang.Integer> getCounts(java.util.Collection<K> c)
Takes a collection of objects and returns a Hashtable giving counts for how many times each object appears in the collection

Type Parameters:
K -
Parameters:
c -
Returns:

getMostCommonElements

public static <K> java.lang.Object[] getMostCommonElements(java.util.Collection<K> c)
Returns the most frequent element in a collection. If there is a tie, it returns all elements tied for the first place.

Type Parameters:
K -
Parameters:
c -
Returns: