Constructor and Description |
---|
CollectionUtils() |
Modifier and Type | Method and Description |
---|---|
static <E> Map<E,Integer> |
getCardinalityMap(Collection<E> col)
Returns a
Map mapping each unique element in
the given Collection to an Integer
representing the number of occurances of that element
in the Collection . |
static <E> Collection<E> |
intersection(Collection<E> a,
Collection<E> b)
Returns a
Collection containing the intersection
of the given Collection s. |
static <E> List<E> |
iteratorToList(Iterator<E> it) |
static <K,V> Map<K,V> |
mergeMaps(Map<K,V>[] maps)
Take a series of
Map s and merge
them where the ordering of the array from 0..n
is the dominant order. |
static <K,V> Map<K,V> |
mergeMaps(Map<K,V> dominantMap,
Map<K,V> recessiveMap)
Take a dominant and recessive Map and merge the key:value
pairs where the recessive Map may add key:value pairs to the dominant
Map but may not override any existing key:value pairs.
|
static <T> Collection<T> |
subtract(Collection<T> a,
Collection<T> b)
Returns a
Collection containing a - b. |
public static <K,V> Map<K,V> mergeMaps(Map<K,V> dominantMap, Map<K,V> recessiveMap)
dominantMap
- Dominant Map.recessiveMap
- Recessive Map.public static <K,V> Map<K,V> mergeMaps(Map<K,V>[] maps)
Map
s and merge
them where the ordering of the array from 0..n
is the dominant order.maps
- An array of Maps to merge.public static <E> Collection<E> intersection(Collection<E> a, Collection<E> b)
Collection
containing the intersection
of the given Collection
s.
The cardinality of each element in the returned Collection
will be equal to the minimum of the cardinality of that element
in the two given Collection
s.
a
- The first collectionb
- The second collectionCollection.retainAll(java.util.Collection<?>)
public static <T> Collection<T> subtract(Collection<T> a, Collection<T> b)
Collection
containing a - b.
The cardinality of each element e in the returned Collection
will be the cardinality of e in a minus the cardinality
of e in b, or zero, whichever is greater.a
- The start collectionb
- The collection that will be subtractedCollection.removeAll(java.util.Collection<?>)
public static <E> Map<E,Integer> getCardinalityMap(Collection<E> col)
Map
mapping each unique element in
the given Collection
to an Integer
representing the number of occurances of that element
in the Collection
.
An entry that maps to null indicates that the
element does not appear in the given Collection
.col
- The collection to count cardinalities forCopyright © 2001-2013 Codehaus. All Rights Reserved.