us.ihmc.utilities.containers
Class ContainerTools

java.lang.Object
  extended by us.ihmc.utilities.containers.ContainerTools

public class ContainerTools
extends java.lang.Object

Class contains static functions that are useful when dealing with container classes such as ArrayList, EnumMap, HashMap, etc.


Method Summary
static
<T extends java.lang.Comparable<? super T>>
java.util.List<T>
asSortedList(java.util.Collection<T> c)
           
static
<K extends java.lang.Enum<K>,V>
java.util.EnumMap<K,V>
createEnumMap(java.lang.Class<K> keyType)
          Creates a new EnumMap.
static
<E> java.util.TreeSet<E>
findLargestElements(java.util.Collection<? extends E> collection, java.util.Comparator<? super E> comparator, int n)
          Finds the n largest elements of the given collection, according to the specified comparator.
static
<K1 extends java.lang.Enum<K1>,K2 extends java.lang.Enum<K2>,V>
java.util.ArrayList<V>
flatten(java.util.EnumMap<K1,java.util.EnumMap<K2,V>> mapOfMaps)
          Takes all the elements in an EnumMap of EnumMaps and puts them in an ArrayList
static
<T> boolean
removeByReference(java.util.List<T> list, T o)
          Removes an object from a list *by reference*, instead of using the equals method
static
<K1 extends java.lang.Enum<K1>,K2 extends java.lang.Enum<K2>>
double[][]
toArrayOfArrays(java.util.EnumMap<K1,java.util.EnumMap<K2,java.lang.Double>> mapOfMaps)
          Takes all the elements in an EnumMap of EnumMaps and puts them into an array of arrays
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createEnumMap

public static <K extends java.lang.Enum<K>,V> java.util.EnumMap<K,V> createEnumMap(java.lang.Class<K> keyType)
Creates a new EnumMap. This method is a shortcut to make construction less verbose.

Type Parameters:
K - key type
V - value type
Parameters:
keyType - runtime key type
Returns:
a new EnumMap

findLargestElements

public static <E> java.util.TreeSet<E> findLargestElements(java.util.Collection<? extends E> collection,
                                                           java.util.Comparator<? super E> comparator,
                                                           int n)
Finds the n largest elements of the given collection, according to the specified comparator.

Type Parameters:
E - collection type
Parameters:
collection - the collection from which the largest elements need to be found
comparator - compares the elements of the collection.
n - maximum number of elements contained in the returned set
Returns:

flatten

public static <K1 extends java.lang.Enum<K1>,K2 extends java.lang.Enum<K2>,V> java.util.ArrayList<V> flatten(java.util.EnumMap<K1,java.util.EnumMap<K2,V>> mapOfMaps)
Takes all the elements in an EnumMap of EnumMaps and puts them in an ArrayList


toArrayOfArrays

public static <K1 extends java.lang.Enum<K1>,K2 extends java.lang.Enum<K2>> double[][] toArrayOfArrays(java.util.EnumMap<K1,java.util.EnumMap<K2,java.lang.Double>> mapOfMaps)
Takes all the elements in an EnumMap of EnumMaps and puts them into an array of arrays


asSortedList

public static <T extends java.lang.Comparable<? super T>> java.util.List<T> asSortedList(java.util.Collection<T> c)

removeByReference

public static <T> boolean removeByReference(java.util.List<T> list,
                                            T o)
Removes an object from a list *by reference*, instead of using the equals method

Parameters:
list -
o -
Returns: