Name
rotate function template — Rotates elements in a range
Synopsis
template<typename FwdIter>
void rotate(FwdIter first, FwdIter middle, FwdIter last);
The rotate
function
template rotates elements in the range [first
, last
) to the left so that the items in the
range [middle
, last
) are moved to the start of the new
sequence. Elements in the range [first
, middle
) are rotated to the end. See Figure 13-16 for an
example.
Technical Notes
For all n in [0,
last - first), the rotate
function template moves *(first +
n) into position first + (n + (last - middle)) % (last - first).
Complexity is linear: at most last - first swaps are performed.
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.