Package org.h2.util

Class Permutations<T>

  • Type Parameters:
    T - the element type

    public class Permutations<T>
    extends java.lang.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 Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> Permutations<T> create​(T[] in, T[] out)
      Create a new permutations object.
      static <T> Permutations<T> create​(T[] in, T[] out, int m)
      Create a new permutations object.
      boolean next()
      Go to the next lineup, and if available, fill the target array.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • 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