Package groovy.util

Class Iterables

java.lang.Object
groovy.util.Iterables

public class Iterables extends Object
Provides some iterable based generators.
Since:
5.0.0
  • Constructor Details

    • Iterables

      public Iterables()
  • Method Details

    • combine

      public static <K, T> Iterator<Map<K,T>> combine(Map<K,? extends Iterable<T>> map)
      An iterator returning a map for each combination of elements the iterables sources.
       assert Iterables.combine(x: 1..2, y: 'a'..'c').collect().toString()
           == '[[x:1, y:a], [x:1, y:b], [x:1, y:c], [x:2, y:a], [x:2, y:b], [x:2, y:c]]'
       assert Iterables.combine(x: 1..3, y: 'a'..'b').collect().toString()
           == '[[x:1, y:a], [x:1, y:b], [x:2, y:a], [x:2, y:b], [x:3, y:a], [x:3, y:b]]'
       
      Parameters:
      map - the named source iterables
      Returns:
      the output iterator of named combinations