Overview | Package | Class | Deprecated | Index | Help
| Groovy 1.7.10
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## groovy.util
[Java] Class GroovyCollections

    java.lang.Object
      groovy.util.GroovyCollections

    public class GroovyCollections
    extends Object

A Collections utility class

Authors:
  Paul King
  Jim White

Method Summary
`static List` | `combinations(Object[] collections)` Finds all combinations of items from the given collections.
`static List` | `combinations(Collection collections)` Finds all combinations of items from the given collections.
`static T` | `max(T[] items)` Selects the maximum value found in an array of items, so min([2, 4, 6] as Object[]) == 6.
`static T` | `max(Collection items)` Selects the maximum value found in a collection
`static T` | `min(T[] items)` Selects the minimum value found in an array of items, so min([2, 4, 6] as Object[]) == 2.
`static T` | `min(Collection items)` Selects the minimum value found in a collection of items.
`static Set` | `subsequences(List items)` Finds all non-null subsequences of a list.
`static Object` | `sum(Object[] 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(Object[] lists)` Transposes an array of lists.
`static List` | `transpose(List lists)` Transposes the given lists.

Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll

Method Detail

### combinations

    public static List combinations(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

    public static List combinations(Collection collections)

  Finds all combinations of items from the given 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 given collections
  Returns:
    a List of the combinations found

### max

    public static T max(T[] 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

    public static T max(Collection items)

  Selects the maximum value found in a collection
  Parameters:
    `items` - a Collection
  Returns:
    the maximum value

### min

    public static T min(T[] 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

    public static T min(Collection items)

  Selects the minimum value found in a collection of items.
  Parameters:
    `items` - a Collection
  Returns:
    the minimum value

### subsequences

    public static Set subsequences(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 Object sum(Object[] items)

  Sums all the items from an array of items.
  Parameters:
    `items` - an array of items
  Returns:
    the sum of the items

### sum

    public static Object sum(Collection items)

  Sums all the items from a collection of items.
  Parameters:
    `items` - a collection of items
  Returns:
    the sum of the items

### transpose

    public static List transpose(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 List transpose(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

Copyright © 2003-2010 The Codehaus. All rights reserved.