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 java.lang.ObjectA 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.booleannext()Go to the next lineup, and if available, fill the target array.
-
-
-
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 arrayout- 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 arrayout- the target arraym- 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
-
-