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

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -