Module rotate

Source

Functionsยง

ptr_rotate ๐Ÿ”’ โš 
Rotates the range [mid-left, mid+right) such that the element at mid becomes the first element. Equivalently, rotates the range left elements to the left or right elements to the right.
ptr_rotate_gcd ๐Ÿ”’ โš 
Algorithm 2 is used for small values of left + right or for large T. The elements are moved into their final positions one at a time starting at mid - left and advancing by right steps modulo left + right, such that only one temporary is needed. Eventually, we arrive back at mid - left. However, if gcd(left + right, right) is not 1, the above steps skipped over elements. For example:
ptr_rotate_memmove ๐Ÿ”’ โš 
Algorithm 1 is used if min(left, right) is small enough to fit onto a stack buffer. The min(left, right) elements are copied onto the buffer, memmove is applied to the others, and the ones on the buffer are moved back into the hole on the opposite side of where they originated.
ptr_rotate_swap ๐Ÿ”’ โš 
Algorithm 3 utilizes repeated swapping of min(left, right) elements.

Type Aliasesยง

BufType ๐Ÿ”’