public class CollectionUtil extends Object
| Constructor and Description |
|---|
CollectionUtil() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addIfNotNull(Object item,
Collection collection) |
static Collection |
collect(Collection collection,
Block block)
The Smalltalk #collect method.
|
static List |
combinations(List original)
Returns a List of Lists: all combinations of the elements of the given List.
|
static List |
combinations(List original,
int maxCombinationSize)
Returns a List of Lists: all combinations of the elements of the given List.
|
static List |
combinations(List original,
int maxCombinationSize,
Object mandatoryItem)
Returns a List of Lists: all combinations of the elements of the given List.
|
static Collection |
concatenate(Collection collections) |
static boolean |
containsReference(Object[] objects,
Object o) |
static Map |
createMap(Class mapClass,
Object[] alternatingKeysAndValues) |
static Map |
createMap(Object[] alternatingKeysAndValues) |
static Collection |
filterByClass(Collection collection,
Class c)
Modifies and returns the collection.
|
static Object |
get(Class c,
Map map) |
static Object |
ifNotIn(Object o,
Collection c,
Object alternative) |
static int |
indexOf(Object o,
Object[] objects) |
static Map |
inverse(Map map) |
static List[] |
keysAndCorrespondingValues(Map map)
The nth key corresponds to the nth value
|
static Object |
randomElement(List list) |
static Collection |
removeDuplicates(Collection original)
Brute force, for when HashSet and TreeSet won't work (e.g.
|
static void |
removeKeys(Collection keys,
Map map) |
static void |
resize(List list,
int newSize) |
static List |
reverse(List list) |
static SortedSet |
reverseSortedSet(int[] ints) |
static Collection |
select(Collection collection,
Block block)
The Smalltalk #select method.
|
static void |
setIfNull(int i,
List list,
String value) |
static Collection |
stretch(Collection source,
Collection destination,
int destinationSize)
Data is evenly discarded or duplicated to attain the new size
|
public static List combinations(List original, int maxCombinationSize)
maxCombinationSize - combinations larger than this value are discardedpublic static List combinations(List original, int maxCombinationSize, Object mandatoryItem)
maxCombinationSize - combinations larger than this value are discardedmandatoryItem - an item that all returned combinations must contain,
or null to leave unspecifiedpublic static List combinations(List original)
public static void removeKeys(Collection keys, Map map)
public static List[] keysAndCorrespondingValues(Map map)
public static Collection concatenate(Collection collections)
public static SortedSet reverseSortedSet(int[] ints)
public static Collection stretch(Collection source, Collection destination, int destinationSize)
public static Object ifNotIn(Object o, Collection c, Object alternative)
public static void resize(List list, int newSize)
public static Collection removeDuplicates(Collection original)
public static void addIfNotNull(Object item, Collection collection)
public static Collection filterByClass(Collection collection, Class c)
public static Collection collect(Collection collection, Block block)
public static Collection select(Collection collection, Block block)
Copyright © 2015. All rights reserved.