algorithm - C++ Vector elements' index -


#include <iostream> #include <vector>  int main() {  std::vector<int> v = {1, 2, 3, 4};   } 

is there efficient way push "4" 1's place , push every other element next index. vector's element order {4, 1, 2, 3} instead. have thought of few ways, wondering if there elegant , more efficient way it.

thanks in advance!

this looks tailor-made std::rotate:

std::rotate(v.begin(), v.begin()+3, v.end()); 

Comments

Popular posts from this blog

java - Static nested class instance -

Python Pandas join aggregated tables -

process - Python What is the difference between a Pool of worker processes and just running multiple Processes? -