Groovy Documentation

groovy.util
[Java] Class GroovyCollections

java.lang.Object
  groovy.util.GroovyCollections

public class GroovyCollections
extends java.lang.Object

A Collections utility class

Authors:
Paul King
Jim White


Method Summary
static java.util.List combinations(java.lang.Object[] collections)

Finds all combinations of items from the given collections.

static java.util.List combinations(java.util.Collection collections)

@param collections the given collections

static java.util.List combinations(java.lang.Iterable collections)

Finds all combinations of items from the given Iterable aggregate of collections.

static java.lang.Object max(java.lang.Object[] items)

Selects the maximum value found in an array of items, so min([2, 4, 6] as Object[]) == 6.

static java.lang.Object max(java.util.Collection items)

@deprecated use max(Iterable)

static java.lang.Object max(java.lang.Iterable items)

Selects the maximum value found in an Iterable.

static java.lang.Object min(java.lang.Object[] items)

Selects the minimum value found in an array of items, so min([2, 4, 6] as Object[]) == 2.

static java.lang.Object min(java.util.Collection items)

@deprecated use min(Iterable)

static java.lang.Object min(java.lang.Iterable items)

Selects the minimum value found in an Iterable of items.

static java.util.Set subsequences(java.util.List items)

Finds all non-null subsequences of a list.

static java.lang.Object sum(java.lang.Object[] items)

Sums all the items from an array of items.

static java.lang.Object sum(java.util.Collection items)

@deprecated use sum(Iterable)

static java.lang.Object sum(java.lang.Iterable items)

Sums all the given items.

static java.util.List transpose(java.lang.Object[] lists)

Transposes an array of lists.

static java.util.List transpose(java.util.List lists)

Transposes the given lists.

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Method Detail

combinations

public static java.util.List combinations(java.lang.Object[] collections)
Finds all combinations of items from the given collections.
Parameters:
collections - the given collections
Returns:
a List of the combinations found
See Also:
combinations(Collection)


combinations

@java.lang.Deprecatedpublic static List combinations(Collection collections) {
public static java.util.List combinations(java.util.Collection collections)
deprecated:
use combinations(Iterable)
Parameters:
collections - the given collections


combinations

public static java.util.List combinations(java.lang.Iterable collections)
Finds all combinations of items from the given Iterable aggregate of collections. So, 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']].
Parameters:
collections - the Iterable of given collections
Returns:
a List of the combinations found
Since:
2.2.0


max

public static java.lang.Object max(java.lang.Object[] items)
Selects the maximum value found in an array of items, so min([2, 4, 6] as Object[]) == 6.
Parameters:
items - an array of items
Returns:
the maximum value


max

@java.lang.Deprecatedpublic static  T max(Collection items) {
public static java.lang.Object max(java.util.Collection items)
deprecated:
use max(Iterable)


max

public static java.lang.Object max(java.lang.Iterable items)
Selects the maximum value found in an Iterable.
Parameters:
items - a Collection
Returns:
the maximum value
Since:
2.2.0


min

public static java.lang.Object min(java.lang.Object[] items)
Selects the minimum value found in an array of items, so min([2, 4, 6] as Object[]) == 2.
Parameters:
items - an array of items
Returns:
the minimum value


min

@java.lang.Deprecatedpublic static  T min(Collection items) {
public static java.lang.Object min(java.util.Collection items)
deprecated:
use min(Iterable)


min

public static java.lang.Object min(java.lang.Iterable items)
Selects the minimum value found in an Iterable of items.
Parameters:
items - an Iterable
Returns:
the minimum value
Since:
2.2.0


subsequences

public static java.util.Set subsequences(java.util.List items)
Finds all non-null subsequences of a list. E.g. subsequences([1, 2, 3]) would be: [[1, 2, 3], [1, 3], [2, 3], [1, 2], [1], [2], [3]]
Parameters:
items - the List of items
Returns:
the subsequences from items


sum

public static java.lang.Object sum(java.lang.Object[] items)
Sums all the items from an array of items.
Parameters:
items - an array of items
Returns:
the sum of the items


sum

@java.lang.Deprecatedpublic static Object sum(Collection items) {
public static java.lang.Object sum(java.util.Collection items)
deprecated:
use sum(Iterable)


sum

public static java.lang.Object sum(java.lang.Iterable items)
Sums all the given items.
Parameters:
items - an Iterable of items
Returns:
the sum of the item
Since:
2.2.0


transpose

public static java.util.List transpose(java.lang.Object[] lists)
Transposes an array of lists.
Parameters:
lists - the given lists
Returns:
a List of the transposed lists
See Also:
transpose(List)


transpose

public static java.util.List transpose(java.util.List lists)
Transposes the given lists. So, transpose([['a', 'b'], [1, 2]]) is [['a', 1], ['b', 2]] and transpose([['a', 'b', 'c']]) is [['a'], ['b'], ['c']].
Parameters:
lists - the given lists
Returns:
a List of the transposed lists


 

Groovy Documentation