|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectedu.umd.cfar.lamp.viper.util.Permuter
This class takes in an array of Objects and runs through all possible permutations.
Combinator| Constructor Summary | |
Permuter(java.lang.Object[] stringToPermute)
Constructs a new Permuter to iterate over all permutations of the given string. |
|
| Method Summary | |
static int |
factorial(int x)
Gets the factorial of an integer. |
java.lang.Object[] |
getNextPermutation()
Based on Dijkstra's method for doing this sort of thing. |
java.lang.String |
toString()
Gets a string representation of the current permutation. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public Permuter(java.lang.Object[] stringToPermute)
stringToPermute - The Objects to rearrange.| Method Detail |
public static int factorial(int x)
x - The integer.
public java.lang.Object[] getNextPermutation()
private void getNext()
{
int i = N - 1;
while (Value[i-1] >= Value[i])
i = i-1;
int j = N;
while (Value[j-1] <= Value[i-1])
j = j-1;
swap(i-1, j-1);
i++; j = N;
while (i < j) {
swap(i-1, j-1);
i++;
j--;
}
}
public java.lang.String toString()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||