3 Mar
2006
3 Mar
'06
9:31 p.m.
Meryl Silverburgh wrote:
I have a vector<float> source vector and a vector<int> keys.
I would like to remove all element in the keys from the source vector.
i.e. if the keys array is <1, 3, 4, 5> I would like to remove 1st, 3rd , 4th, 5th element from the source vector.
how can I do that?
Thank you.
I think this is as simple as possible: sort(keys.begin(), keys.end(), greater<int>()); // maybe use std::unique to remove duplicates BOOST_FOREACH(int key, keys) { assert(key >= 0); assert(key < data.size()); data.erase(boost::next(data.begin(), key)); }