template <class ForwardIterator, class OutputIterator> OutputIterator rotate_copy (ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result); |
template <class ForwardIterator, class OutputIterator> OutputIterator rotate_copy (ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result) { result=std::copy (middle,last,result); return std::copy (first,middle,result); } |
// rotate_copy algorithm example #include <iostream> // std::cout #include <algorithm> // std::rotate_copy #include <vector> // std::vector int main () { int myints[] = {10,20,30,40,50,60,70}; std::vector<int> myvector (7); std::rotate_copy(myints,myints+3,myints+7,myvector.begin()); // print out content: std::cout << "myvector contains:"; for (std::vector<int>::iterator it=myvector.begin(); it!=myvector.end(); ++it) std::cout << ' ' << *it; std::cout << '\n'; return 0; } |
rotate | 旋转元素(函数模板) |
reverse | 复制并反转元素(函数模板) |
random_shuffle | 随机重新排列范围内的元素(函数模板) |
copy | 复制范围的元素(函数模板) |