VOOZH about

URL: https://www.geeksforgeeks.org/cpp/stdrotate-vs-stdrotate_copy-c-stl/

⇱ std::rotate vs std::rotate_copy in C++ STL - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

std::rotate vs std::rotate_copy in C++ STL

Last Updated : 5 Aug, 2017
  1. rotate in STL:It rotates the order of the elements in the range [first, last), in such a way that the element pointed by middle becomes the new first element, i, e, to the left. Output:
    arr contains: 4 5 6 7 8 9 1 2 3
    
  2. rotate_copy:It copies the elements in the range [first, last) to the range beginning at result, but rotates the order of the elements in such a way that the element pointed by middle becomes the first element in the resulting range, i.e, left rotate.
Output:
gfg contains: 40 50 60 70 10 20 30
Comment
Article Tags: