For removing an iterator from std::vector I can do these two things:
std::vector<int>& vec = myNumbers; // use shorter name
vec.erase(std::remove(vec.begin(), vec.end(), number_in), vec.end());
Or I can do this:
auto it = find(vec.begin(), vec.end(), number_in);
vec.erase(it);
The second is more intuitive, I guess, but which one is faster?
EDIT: Elements in vector are unique and we don't have to worry to delete several elements at once.
number_in, and the second removes one of elements which arenumber_in.findthen overwrite the found element withvec.back(), thenvec.pop_back(). That makes the post-finderasepart of the operation O(1), instead of linear in the number of elements thereafter in thevector(as it shuffles them front-ward).