Permutes range into the perm permutation.
The algorithm has a constant runtime complexity with respect to the number of
permutations created.
Due to the number of unique values of ulong only the first 21 elements of
range can be permuted. The rest of the range will therefore not be
permuted.
This algorithm uses the Lehmer
Code.
The algorithm works as follows:
1 autopem = [4,0,4,1,0,0,0]; // permutation 2982 in factorial2 autosrc = [0,1,2,3,4,5,6]; // the range to permutate3 4 autoi = 0; // range index5 // range index iterates pem and src in sync6 // pem[i] + i is used as index into src7 // first src[pem[i] + i] is stored in t8 autot = 4; // tmp value9 src = [0,1,2,3,n,5,6];
10 11 // then the values between i and pem[i] + i are moved one12 // to the right13 src = [n,0,1,2,3,5,6];
14 // at last t is inserted into position i15 src = [4,0,1,2,3,5,6];
16 // finally i is incremented17 ++i;
18 19 // this process is repeated while i < pem.length20 21 t = 0;
22 src = [4,n,1,2,3,5,6];
23 src = [4,0,1,2,3,5,6];
24 ++i;
25 t = 6;
26 src = [4,0,1,2,3,5,n];
27 src = [4,0,n,1,2,3,5];
28 src = [4,0,6,1,2,3,5];
Permutes range into the perm permutation. The algorithm has a constant runtime complexity with respect to the number of permutations created. Due to the number of unique values of ulong only the first 21 elements of range can be permuted. The rest of the range will therefore not be permuted. This algorithm uses the Lehmer Code.
The algorithm works as follows: