groovy.util
Class GroovyCollections

A Collections utility class

author:
Paul King

 
Constructor Summary
GroovyCollections()
           
 
Method Summary
static List combinations(def lists)
           Finds all combinations of items from an array of lists.
static List combinations(Collection lists)
           Finds all combinations of items from a collection of lists.
static Object max(def items)
           Selects the maximum value found in an array of items, so min([2, 4, 6] as Object[]) == 6.
static Object max(Collection items)
           Selects the maximum value found in a collection
static Object min(def items)
           Selects the minimum value found in an array of items, so min([2, 4, 6] as Object[]) == 2.
static Object min(Collection items)
           Selects the minimum value found in a collection of items.
static Object sum(def items)
           Sums all the items from an array of items.
static Object sum(Collection items)
           Sums all the items from a collection of items.
static List transpose(def lists)
           Transposes an array of lists.
static List transpose(Collection lists)
           Transposes a collection of lists.
 

Constructor Detail

GroovyCollections

GroovyCollections()


Method Detail

combinations

public static List combinations(def lists)
Finds all combinations of items from an array of lists.
param:
lists an array of lists
return:
a List of the combinations found
see:
#combinations(Collection)


combinations

public static List combinations(Collection lists)
Finds all combinations of items from a collection of lists. 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]].
param:
lists a Collection of lists
return:
a List of the combinations found


max

public static Object max(def items)
Selects the maximum value found in an array of items, so min([2, 4, 6] as Object[]) == 6.
param:
items an array of items
return:
the maximum value


max

public static Object max(Collection items)
Selects the maximum value found in a collection
param:
items a Collection
return:
the maximum value


min

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


min

public static Object min(Collection items)
Selects the minimum value found in a collection of items.
param:
items a Collection
return:
the minimum value


sum

public static Object sum(def items)
Sums all the items from an array of items.
param:
items an array of items
return:
the sum of the items


sum

public static Object sum(Collection items)
Sums all the items from a collection of items.
param:
items a collection of items
return:
the sum of the items


transpose

public static List transpose(def lists)
Transposes an array of lists.
param:
lists an array of lists
return:
a List of the transposed lists
see:
#transpose(Collection)


transpose

public static List transpose(Collection lists)
Transposes a collection of lists. So, transpose([['a', 'b'], [1, 2]]) is [['a', 1], ['b', 2]] and. transpose([['a', 'b', 'c']]) is [['a'], ['b'], ['c']] and.
param:
lists a Collection of lists
return:
a List of the transposed lists