>> using std::remove() on an std::list won't use that advantage, it will be as slow as with an std::vector.
Which is why you should use the list member function remove() instead of the generic algorithm if you do switch to lists.
Wha?? Whose using std::remove()? No shuffling here:
Code:
myList.remove("Mary");
Unhook the pointers to "Mary", redirect them to the previous and next elements in the list, bingo-bango-bongo..."Mary" is in the bin:
Code:
myList.remove("Mary");
copy(myList.begin(), myList.end(), ostream_iterator<string>(cout, " "));
cout<<endl;
Compare to:
Code:
remove(myList.begin(), myList.end(), "Mary");
myList.remove("Mary");
copy(myList.begin(), myList.end(), ostream_iterator<string>(cout, " "));
cout<<endl;
Shuffle up and deal.