To remove all instances of a particular value from a C++ STL vector, you should use the _______ algorithm.
- find
- sort
- erase
- remove
While erase can remove elements from a vector, to efficiently remove all instances of a value, you'd first use remove to move those elements to the end and then use erase. This is known as the "erase-remove" idiom in C++.
Loading...
Related Quiz
- What is the impact of a function having a default argument?
- What is the purpose of the this pointer in C++?
- What is the purpose of the modulus operator (%) in C++?
- Which access specifier allows a class member to be accessible only within its own class and friends?
- When a float is converted to an int, the value is _______.