template <class ForwardIterator> inline ForwardIterator rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
DescriptionRotate rotates the elements in a range. That is, the element pointed to by middle is moved to the position first, the element pointed to by middle + 1 is moved to the position first + 1, and so on. One way to think about this operation is that it exchanges the two ranges [first, middle) and [middle, last). Formally, for every integer n such that 0 <= n < last - first, the element *(first + n) is assigned to *(first + (n + (last - middle)) % (last - first)). Rotate returns first + (last - middle).
DefinitionDefined in the standard header algorithm, and in the nonstandard backward-compatibility header algo.h.
Requirements on types
ComplexityLinear. At most last - first swaps are performed. 
char alpha = "abcdefghijklmnopqrstuvwxyz"; rotate(alpha, alpha + 13, alpha + 26); printf("%s\n", alpha); // The output is nopqrstuvwxyzabcdefghijklm
 It follows from these two requirements that [first, last) is a valid range.
Copyright © 1999 Silicon Graphics, Inc. All Rights Reserved. TrademarkInformation