Fairly Simple Question about rotate function for vector
Posted on 2004-11-21
Hello. I want to create a function that will take a vector that has these elements:
In that order, and rotate them about a specific point...say 3, so that the vector's contents would look like this:
I have found an incredibly easy method to do it with the vector.at(), however, I would like to do it using iterators. Here is my code, however the vector isn't rotated. My question is, what is going wrong with my code?
template < typename t_iterator >
void rotate_around( t_iterator &start, t_iterator &middle, t_iterator &end )
unsigned int c=0;
for( t_iterator i = middle; i!=(start+c); i-- )
std::swap( *middle, *(middle-1) );
Thanks in advance.