csli.util.collections
Class CollectionUtils

java.lang.Object
  extended by csli.util.collections.CollectionUtils

public class CollectionUtils
extends Object


Constructor Summary
CollectionUtils()
           
 
Method Summary
static
<K,V> Map<K,V>
asMap(K[] keyArray, V[] valueArray)
          Takes an array of keys and an array of values, and maps the former to the latter.
static
<E> Set<E>
asSet(E[] array)
           
static
<E> SortedSet<E>
asSortedSet(E[] array)
           
static
<K,V> List<V>
get(Map<K,V> map, K... keys)
          Get the values corresponding to several keys at once.
static void main(String[] args)
           
static
<E> List<E>
newList(E... args)
          Returns a new List that contains the given arguments.
static
<K,V> Map<K,V>
newMap(K key1, V value1, Object... args)
          Returns a new map that contains the given arguments, treating them as a list of alternating keys and values: Map map = newMap(1, "george", 2, "martha"); will produce the map {1=george, 2=martha}.
static
<E> Set<E>
newSet(E... args)
          Returns a new Set that contains the given arguments.
static
<E> SortedSet<E>
newSortedSet(E... args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollectionUtils

public CollectionUtils()
Method Detail

newList

public static <E> List<E> newList(E... args)
Returns a new List that contains the given arguments.

Returns:

newSet

public static <E> Set<E> newSet(E... args)
Returns a new Set that contains the given arguments.

Returns:

newSortedSet

public static <E> SortedSet<E> newSortedSet(E... args)

newMap

public static <K,V> Map<K,V> newMap(K key1,
                                    V value1,
                                    Object... args)
Returns a new map that contains the given arguments, treating them as a list of alternating keys and values: Map map = newMap(1, "george", 2, "martha"); will produce the map {1=george, 2=martha}. Assumes that we get an even number of arguments of alternating type.

Returns:

asSet

public static <E> Set<E> asSet(E[] array)

asSortedSet

public static <E> SortedSet<E> asSortedSet(E[] array)

asMap

public static <K,V> Map<K,V> asMap(K[] keyArray,
                                   V[] valueArray)
Takes an array of keys and an array of values, and maps the former to the latter. Raises an assert if the two arrays have different lengths.

Type Parameters:
K -
V -
Parameters:
keyArray -
valueArray -
Returns:

get

public static <K,V> List<V> get(Map<K,V> map,
                                K... keys)
Get the values corresponding to several keys at once.

Type Parameters:
K -
V -
Parameters:
keys -
Returns:

main

public static void main(String[] args)