org.deegree.commons.utils
Class CollectionUtils
java.lang.Object
org.deegree.commons.utils.CollectionUtils
public class CollectionUtils
- extends Object
CollectionUtils
- Version:
- $Revision: 21302 $, $Date: 2009-12-08 09:30:46 +0100 (Di, 08 Dez 2009) $
- Author:
- Andreas Schmitz, last edited by: $Author: aschmitz $
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DOUBLE_PRINTER
public static final CollectionUtils.Mapper<String,double[]> DOUBLE_PRINTER
- Use like this: System.out.println(map(List object, DOUBLE_PRINTER)) Unfortunately, a generic version
for all primitive-arrays is not possible...
AND
public static final CollectionUtils.Reducer<Boolean> AND
CollectionUtils
public CollectionUtils()
getArrayPrinter
public static <T> CollectionUtils.Mapper<String,T[]> getArrayPrinter()
- Type Parameters:
T
-
- Returns:
- a mapper to output an object array
getInstanceofMapper
public static <T> CollectionUtils.Mapper<Boolean,T> getInstanceofMapper(Class<?> c)
- Type Parameters:
T
- - Parameters:
c
-
- Returns:
- a list of booleans, true if u instanceof c
removeDuplicates
public static <T> List<T> removeDuplicates(List<T> list)
- Type Parameters:
T
- - Parameters:
list
-
- Returns:
- removes any duplicates in the list. Keeps the first occurrence of duplicates.
unzip
public static <T,U> Pair<ArrayList<T>,ArrayList<U>> unzip(Collection<Pair<T,U>> col)
- Type Parameters:
T
- U
- - Parameters:
col
-
- Returns:
- two separate lists
map
public static <T,U> LinkedList<T> map(U[] col,
CollectionUtils.Mapper<T,U> mapper)
- Wraps a for loop and the creation of a new list.
- Type Parameters:
T
- U
- - Parameters:
col
- mapper
-
- Returns:
- a list where the mapper has been applied to each element in the map
map
public static <T,U> LinkedList<T> map(Collection<U> col,
CollectionUtils.Mapper<T,U> mapper)
- Wraps a for loop and the creation of a new list.
- Type Parameters:
T
- U
- - Parameters:
col
- mapper
-
- Returns:
- a list where the mapper has been applied to each element in the map
reduce
public static <T> T reduce(T identity,
Collection<T> col,
CollectionUtils.Reducer<T> reducer)
- Type Parameters:
T
- - Parameters:
identity
- col
- reducer
-
- Returns:
- the folded value
an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://www.deegree.org]]>