I am wondering why there is no STL function that deletes an element from a vector by swapping it to the end and then removing it. Is there a better data structure than std::vector
if you don't care about the actual order of elements and still want very fast traversal?
Note that using std::remove
and std::erase
is not the same because this is linear time instead of constant time as the order has to be preserved.
没有评论:
发表评论