The Wayback Machine - https://web.archive.org/web/20170512200019/http://zh.cppreference.com:80/w/cpp/algorithm/rotate_copy

std::rotate_copy

来自cppreference.com
< cpp‎ | algorithm

 
 
算法库
执行策略 (C++17)
不修改的序列操作
(C++11)
(C++11)
(C++11)
(C++17)
修改的序列操作
未初始化存储上的操作
划分操作
排序操作
二分查找操作
集合操作(在已排序范围上)
堆操作
(C++11)
最小/最大操作
(C++11)
(C++17)

重排
数值操作
C 库
 
定义于头文件 <algorithm>
template<class ForwardIt, class OutputIt >

OutputIt rotate_copy( ForwardIt first, ForwardIt n_first,

                      ForwardIt last, OutputIt d_first );
的元素复制的范围内[first, last)d_first开始到另一个范围在这样一种方式,该元素n_first成为新的范围的第一个元素,并n_first - 1成为最后一个元素.
原文:
Copies the elements from the range [first, last), to another range beginning at d_first in such a way, that the element n_first becomes the first element of the new range and n_first - 1 becomes the last element.
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里

目录

[编辑]参数

first, last -
元素的范围内,要复制的复本
原文:
the range of elements to copy
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
n_first -
元素移动到新的范围的开始
原文:
the element to move to the beginning of the new range
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
d_first -
开始的目标范围内
原文:
beginning of the destination range
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
类型要求
-
ForwardIt 必须满足 ForwardIterator 的要求。
-
OutputIt 必须满足 OutputIterator 的要求。

[编辑]返回值

输出迭代器复制过去的最后一个元素的元素
原文:
Output iterator to the element past the last element copied.
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里

[编辑]可能的实现

template<class ForwardIt, class OutputIt> OutputIt rotate_copy(ForwardIt first, ForwardIt n_first, ForwardIt last, OutputIt d_first){ d_first =std::copy(n_first, last, d_first);returnstd::copy(first, n_first, d_first);}

[编辑]示例

[编辑]复杂度

线性firstlast之间的距离
原文:
linear in the distance between first and last
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里

[编辑]另请参阅

将区间内的元素旋转
(函数模板)[编辑]
close