| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private final T[] | |
| private final int[] | |
| private final int | |
| private final int | |
| private final T[] |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static < the type T> Permutations | Returns: the generated permutations objectthe source array in, T[] the target array out)Create a new permutations object. |
| public static < the type T> Permutations | Returns: the generated permutations objectthe source array in, T[] the target array out, int the number of output elements to generate m)Create a new permutations object. |
| private void | |
| public boolean | Returns: if a new lineup is availableGo to the next lineup, and if available, fill the target array. |
| private void | |
| private int | Returns: the index or -1 if non is foundGet the index of the first element from the right that is less than its neighbor on the right. |
| hasNext | back to summary |
|---|---|
| private boolean hasNext | |
| in | back to summary |
|---|---|
| private final T[] in | |
| index | back to summary |
|---|---|
| private final int[] index | |
| m | back to summary |
|---|---|
| private final int m | |
| n | back to summary |
|---|---|
| private final int n | |
| out | back to summary |
|---|---|
| private final T[] out | |
| Permutations | back to summary |
|---|---|
| private Permutations(T[] in, T[] out, int m) | |
| create | back to summary |
|---|---|
| public static <T> Permutations Create a new permutations object.
| |
| create | back to summary |
|---|---|
| public static <T> Permutations Create a new permutations object.
| |
| moveIndex | back to summary |
|---|---|
| private void moveIndex() Move the index forward a notch. The algorithm first finds the rightmost index that is less than its neighbor to the right. This is the dip point. The algorithm next finds the least element to the right of the dip that is greater than the dip. That element is switched with the dip. Finally, the list of elements to the right of the dip is reversed. For example, in a permutation of 5 items, the index may be {1, 2, 4, 3, 0}. The dip is 2 the rightmost element less than its neighbor on its right. The least element to the right of 2 that is greater than 2 is 3. These elements are swapped, yielding {1, 3, 4, 2, 0}, and the list right of the dip point is reversed, yielding {1, 3, 0, 2, 4}. | |
| next | back to summary |
|---|---|
| public boolean next() Go to the next lineup, and if available, fill the target array.
| |
| reverseAfter | back to summary |
|---|---|
| private void reverseAfter(int i) Reverse the elements to the right of the specified index.
| |
| rightmostDip | back to summary |
|---|---|
| private int rightmostDip() Get the index of the first element from the right that is less than its neighbor on the right.
| |