Package org.h2.util

Class Permutations<T>

java.lang.Object
org.h2.util.Permutations<T>
Type Parameters:
T - the element type

public class Permutations<T> extends Object
A class to iterate over all permutations of an array. The algorithm is from Applied Combinatorics, by Alan Tucker as implemented in http://www.koders.com/java/fidD3445CD11B1DC687F6B8911075E7F01E23171553.aspx
  • Method Details

    • create

      public static <T> Permutations<T> create(T[] in, T[] out)
      Create a new permutations object.
      Type Parameters:
      T - the type
      Parameters:
      in - the source array
      out - the target array
      Returns:
      the generated permutations object
    • create

      public static <T> Permutations<T> create(T[] in, T[] out, int m)
      Create a new permutations object.
      Type Parameters:
      T - the type
      Parameters:
      in - the source array
      out - the target array
      m - the number of output elements to generate
      Returns:
      the generated permutations object
    • next

      public boolean next()
      Go to the next lineup, and if available, fill the target array.
      Returns:
      if a new lineup is available