STL: rotate
rotate
Exchanges the elements in two adjacent ranges.
template<class ForwardIterator> void rotate( ForwardIterator _First, ForwardIterator _Middle, ForwardIterator _Last );
rotate_copy
Exchanges the elements in two adjacent ranges within a source range and copies the result to a destination range.
template<class ForwardIterator, class OutputIterator> OutputIterator rotate_copy( ForwardIterator _First, ForwardIterator _Middle, ForwardIterator _Last, OutputIterator _Result );
rotate和swap_ranges()功能颇为近似,但是swap_ranges只能交换两个长度相同的区间,rotate却可以交换两个长度不同的区间。所以如果两个区间的长度相同,则优先使用swap_ranges;而区间长度不同时,则使用rotate。