Is there any better way (either faster or with fewer symbols of code) than erasing the element and re-adding it to the back?
template <typename T>
void moveItemToBack(std::vector<T>& v, size_t itemIndex)
{
T tmp(v[itemIndex]);
v.erase(v.begin() + itemIndex);
v.push_back(tmp);
}
std::queue
orstd::dequeue
std::rotate
. It will do what you want but I'm not sure if it would be faster or slower thanpush_back/erase
.