|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--viewer.Permutation
Utility class for permutations
Field Summary | |
static int[] |
factors
Cache of factorial function up to fact(12) (maximum for int) |
Constructor Summary | |
Permutation()
|
Method Summary | |
static long |
ArrToPerm(int[] arr)
Parses array and returns permutation that it represents |
static int |
composePerm(int n,
int i1,
int i2)
Composes permutations given by indexes |
static long |
composePerm(int n,
long p1,
long p2)
Composes two permutations |
static int |
getNthVal(long perm,
int n)
Returns perm(n) |
static long |
IndexToPerm(int n,
int index)
Return permutation by it's index |
static boolean |
isValidPerm(int n,
long perm)
Check if permutation is valid |
static void |
main(java.lang.String[] args)
Test function for permutations |
static int |
PermToIndex(int n,
long perm)
Get permutation's index |
static java.lang.String |
PermToString(int n,
long perm)
Convert permutation to string |
static long |
setNthVal(long perm,
int n,
long val)
Sets perm(n)=val - for building permutations Note: Can create non-valid permutation |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static int[] factors
Constructor Detail |
public Permutation()
Method Detail |
public static int PermToIndex(int n, long perm)
n
- nperm
- Permutation
public static long IndexToPerm(int n, int index)
n
- nindex
- Index of the requested permutation
public static java.lang.String PermToString(int n, long perm)
n
- nperm
- Permuation
public static int getNthVal(long perm, int n)
perm
- Permutationn
- Indexpublic static long setNthVal(long perm, int n, long val)
perm
- Permutation to changen
- nval
- New value for perm(n)
public static long ArrToPerm(int[] arr)
arr
- Array containing permutation
public static long composePerm(int n, long p1, long p2)
n
- np1
- First permutationp2
- Second permutation
public static int composePerm(int n, int i1, int i2)
n
- ni1
- Index of first permutationi2
- Index of second permutation
public static boolean isValidPerm(int n, long perm)
n
- nperm
- Permutation to check
public static void main(java.lang.String[] args)
args
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |