|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jgrapht.experimental.permutation.CompoundPermutationIter
public class CompoundPermutationIter
For permutation like this:
These are the possible compound perm: [$,1,2,a,b,c]
[$,1,2,a,c,b]
[$,1,2,b,a,c]
[$,1,2,b,c,a]
[$,1,2,c,a,b]
[$,1,2,c,b,a]
[$,2,1,a,b,c]
[$,2,1,a,c,b]
[$,2,1,b,a,c]
[$,2,1,b,c,a]
[$,2,1,c,a,b]
[$,2,1,c,b,a]
The overall number is the product of the factorials of each eq. group size; in our example : (1!)x(2!)x(3!)=1x2x6=12. Using the constructor with eq.group sizes and initial order [1,2,3], the result permutations are retrieved as numbers in an array, where [0,1,2,3,4,5] means [$,1,2,a,b,c]:
[0,1,2,3,5,4]
[0,1,2,4,3,5]
etc. etc., till:
[0,2,1,5,4,3] means [$,2,1,c,b,a]
Performance: The implementation tries to advance each time the group zero, if it does not succeed, it tries the next group (1,2 and so on), so: try to put the largest group as the first groups, UNLIKE the example. Performance-wise it is better to do [a,b,c,1,2,$] .The effect is improvement by constant (for example, by 2)
Constructor Summary | |
---|---|
CompoundPermutationIter(int[] equalityGroupsSizesArray)
For the class example, use [1,2,2]. |
Method Summary | |
---|---|
int |
getMax()
|
int[] |
getNext()
Iteration may be one of these two: 1. |
int[] |
getPermAsArray()
Creates and returns a new array which consists of the eq. |
boolean |
hasNext()
|
boolean |
hasNextPermutaions()
|
Object |
next()
|
int[] |
nextPermutation()
|
void |
remove()
UNIMPLEMENTED. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CompoundPermutationIter(int[] equalityGroupsSizesArray)
equalityGroupsSizesArray
- Method Detail |
---|
public Object next()
public int[] getNext()
public int[] getPermAsArray()
public boolean hasNext()
public int getMax()
public int[] nextPermutation()
nextPermutation
in interface ArrayPermutationsIter
public boolean hasNextPermutaions()
hasNextPermutaions
in interface ArrayPermutationsIter
public void remove()
Iterator.remove()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |