Package org.h2.util
Class Permutations<T>
java.lang.Object
org.h2.util.Permutations<T>
- Type Parameters:
T- the element type
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
Modifier and TypeMethodDescriptionstatic <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 Details
-
create
Create a new permutations object.- Type Parameters:
T- the type- Parameters:
in- the source arrayout- the target array- Returns:
- the generated permutations object
-
create
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
-