The examples rely on this definition:
permu_arr_0<13> const q {4, 8, 6, 5, 12, 3, 7, 11, 1, 2, 10, 0, 9};
|
Given these statements:
permu_arr_0<13> p {q};
p.rotate_position (2, 5, 10);
what happens is:
- the element at position 5 is moved to position 2;
- the element at position 6 is moved to position 3;
- the element at position 7 is moved to position 4;
- the element at position 8 is moved to position 5;
- the element at position 9 is moved to position 6;
- the element that was at position 2 is moved to position 7;
- the element that was at position 3 is moved to position 8;
- the element that was at position 4 is moved to position 9.
table 1 — zero-based rotate_position
|
---|
position:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12
| original:
| 4 | 8 | 6 | 5 | 12 | 3 | 7 | 11 | 1 | 2 | 10 | 0 | 9
| (2, 5, 10):
| 4 | 8 | 3 | 7 | 11 | 1 | 2 | 6 | 5 | 12 | 10 | 0 | 9
|
| Given these statements:
permu_arr_0<13> p {q};
p.rotate_value (2, 5, 10);
what happens is:
- element 5 is moved to where element 2 was;
- element 6 is moved to where element 3 was;
- element 7 is moved to where element 4 was;
- element 8 is moved to where element 5 was;
- element 9 is moved to where element 6 was;
- element 2 is moved to where element 7 was;
- element 3 is moved to where element 8 was;
- element 4 is moved to where element 9 was.
table 2 — zero-based rotate_value
|
---|
position:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12
| original:
| 4 | 8 | 6 | 5 | 12 | 3 | 7 | 11 | 1 | 2 | 10 | 0 | 9
| (2, 5, 10):
| 7 | 3 | 9 | 8 | 12 | 6 | 2 | 11 | 1 | 5 | 10 | 0 | 4
|
|
↑ equivalent ↓ | ↑ equivalent ↓
|
Given these statements:
permu_arr_1<13> p {q};
p.rotate_position (3, 6, 11);
what happens is:
- the element at position 6 is moved to position 3;
- the element at position 7 is moved to position 4;
- the element at position 8 is moved to position 5;
- the element at position 9 is moved to position 6;
- the element at position 10 is moved to position 7;
- the element that was at position 3 is moved to position 8;
- the element that was at position 4 is moved to position 9;
- the element that was at position 5 is moved to position 10.
table 3 — one-based rotate_position
|
---|
position:
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13
| original:
| 5 | 9 | 7 | 6 | 13 | 4 | 8 | 12 | 2 | 3 | 11 | 1 | 10
| (3, 6, 11):
| 5 | 9 | 4 | 8 | 12 | 2 | 3 | 7 | 6 | 13 | 11 | 1 | 10
|
Given these statements:
permu_arr_1<13> p {q};
p.rotate_value (3, 6, 11);
what happens is:
- element 6 is moved to where element 3 was;
- element 7 is moved to where element 4 was;
- element 8 is moved to where element 5 was;
- element 9 is moved to where element 6 was;
- element 10 is moved to where element 7 was;
- element 3 is moved to where element 8 was;
- element 4 is moved to where element 9 was;
- element 5 is moved to where element 10 was.
table 4 — one-based rotate_value
|
---|
position:
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13
| original:
| 5 | 9 | 7 | 6 | 13 | 4 | 8 | 12 | 2 | 3 | 11 | 1 | 10
| (3, 6, 11):
| 8 | 4 | 10 | 9 | 13 | 7 | 3 | 12 | 2 | 6 | 11 | 1 | 5
|
| permu_vec_0 and permu_vec_1 work the same way.
| |