11.8.2 Rotating Elements
Rotating Elements inside a Sequence
ForwardIterator rotate (ForwardIterator beg, ForwardIterator newBeg, ForwardIterator end) • Rotates elements in the range [beg,end) so that *newBeg is the new first element after the call. • Since C++11, returns beg+(end-newbeg), which is the new position of the first element. Before C++11, the return type was void. • The caller must ensure that newBeg is a valid position in the range [beg,end); otherwise, the call results in undefined behavior. • Complexity: linear (at most, numElems swaps). The following program demonstrates how to use rotat