Function rotate

Rotates the elements of a union of two ranges.

void rotate(Range) (
  Range front,
  Range back
)
if (isForwardRange!Range && hasSwappableElements!Range);

Performs a left rotation on the given ranges, as if it would be a signle range, so that [front.front, back.front) is a valid range, that is back would continue front.

The elements are moved so, that the first element of back becomes the first element of front without changing the relative order of their elements.

Parameters

NameDescription
Range Range type.
front Left half.
back Right half.

Example

import tanya.algorithm.comparison : equal;

const int[7] expected = [1, 2, 3, 4, 5, 6, 7];
int[7] actual = [5, 6, 3, 4, 1, 2, 7];

rotate(actual[0 .. 2], actual[4 .. 6]);
assert(equal(actual[], expected[]));