JoeC said:
I have a vector of elements, how can I take the first element of a
vector and put it in the end and have all the other elements cycle
down? Ex:
1, 2, 3, 4...
cycle
4, 1, 2 ,3
Your example does not match your description. The following goes with the
specification and not with the example.
Use std::deque instead: std::deque supports efficient insertions and
deletions on either end. Then you can do in constant time:
cont.push_back( cont.front() );
cont.pop_front();
If you need to stay with vector, there is only a linear time solution. In
that case, you could as well go with std::rotate() from <algorithm>:
std::rotate( cont.begin(), cont.begin()+1, cont.end() );
Best
Kai-Uwe Bux