public class GroovyCollections extends Object
Constructor and Description |
---|
GroovyCollections() |
Modifier and Type | Method and Description |
---|---|
static List |
combinations(Collection collections)
Deprecated.
use combinations(Iterable)
|
static List |
combinations(Iterable collections)
Finds all combinations of items from the given Iterable aggregate of collections.
|
static List |
combinations(Object[] collections)
Finds all combinations of items from the given collections.
|
static <T> List<List<T>> |
inits(Iterable<T> collections) |
static <T> T |
max(Collection<T> items)
Deprecated.
use max(Iterable)
|
static <T> T |
max(Iterable<T> items)
Selects the maximum value found in an Iterable.
|
static <T> T |
max(T[] items)
Selects the maximum value found in an array of items, so
min([2, 4, 6] as Object[]) == 6.
|
static <T> T |
min(Collection<T> items)
Deprecated.
use min(Iterable)
|
static <T> T |
min(Iterable<T> items)
Selects the minimum value found in an Iterable of items.
|
static <T> T |
min(T[] items)
Selects the minimum value found in an array of items, so
min([2, 4, 6] as Object[]) == 2.
|
static <T> Set<List<T>> |
subsequences(List<T> items)
Finds all non-null subsequences of a list.
|
static Object |
sum(Collection items)
Deprecated.
use sum(Iterable)
|
static Object |
sum(Iterable items)
Sums all the given items.
|
static Object |
sum(Object[] items)
Sums all the items from an array of items.
|
static <T> List<List<T>> |
tails(Iterable<T> collections) |
static List |
transpose(List lists)
Transposes the given lists.
|
static List |
transpose(Object[] lists)
Transposes an array of lists.
|
public static List combinations(Object[] collections)
collections
- the given collectionscombinations(Collection)
public static <T> Set<List<T>> subsequences(List<T> items)
subsequences([1, 2, 3])
would be:
[[1, 2, 3], [1, 3], [2, 3], [1, 2], [1], [2], [3]]items
- the List of items@Deprecated public static List combinations(Collection collections)
collections
- the given collectionspublic static List combinations(Iterable collections)
combinations([[true, false], [true, false]])
is [[true, true], [false, true], [true, false], [false, false]]
and combinations([['a', 'b'],[1, 2, 3]])
is [['a', 1], ['b', 1], ['a', 2], ['b', 2], ['a', 3], ['b', 3]]
.
If a non-collection item is given, it is treated as a singleton collection,
i.e. combinations([[1, 2], 'x'])
is [[1, 'x'], [2, 'x']]
.
If an empty collection is found within the given collections, the result will be an empty list.collections
- the Iterable of given collectionspublic static List transpose(Object[] lists)
lists
- the given liststranspose(List)
public static List transpose(List lists)
transpose([['a', 'b'], [1, 2]])
is [['a', 1], ['b', 2]]
and
transpose([['a', 'b', 'c']])
is [['a'], ['b'], ['c']]
.lists
- the given listspublic static <T> T min(T[] items)
items
- an array of items@Deprecated public static <T> T min(Collection<T> items)
public static <T> T min(Iterable<T> items)
items
- an Iterablepublic static <T> T max(T[] items)
items
- an array of items@Deprecated public static <T> T max(Collection<T> items)
public static <T> T max(Iterable<T> items)
items
- a Collectionpublic static Object sum(Object[] items)
items
- an array of items@Deprecated public static Object sum(Collection items)