Rotate all elements n steps to the right. If n is negative, rotate to the left.

rotate(x, n = 1L)

ref_rotate(x, n = 1L)

# S3 method for Deque
rotate(x, n = 1L)

# S3 method for Deque
ref_rotate(x, n = 1L)

Arguments

x

any R object.

n

integer number of steps to rotate

Value

For Deque returns the rotated Deque() object.

Details

While rotate uses copy semantics, ref_rotate works by reference, that is, rotates in place on the original object.

Examples

d = deque(1, 2, 3, 4)
rotate(d)
#> |4, 1, 2, 3|
rotate(d, n = 2)
#> |3, 4, 1, 2|