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