unsafe fn ptr_rotate_swap<T>(left: usize, mid: *mut T, right: usize)
Expand description
Algorithm 3 utilizes repeated swapping of min(left, right)
elements.
///
left = 11, right = 4
[4 5 6 7 8 9 10 11 12 13 14 . 0 1 2 3]
^ ^ ^ ^ ^ ^ ^ ^ swapping the right most elements with elements to the left
[4 5 6 7 8 9 10 . 0 1 2 3] 11 12 13 14
^ ^ ^ ^ ^ ^ ^ ^ swapping these
[4 5 6 . 0 1 2 3] 7 8 9 10 11 12 13 14
we cannot swap any more, but a smaller rotation problem is left to solve
when left < right
the swapping happens from the left instead.
ยงSafety
The specified range must be valid for reading and writing.