3 Mar
2006
3 Mar
'06
11:55 p.m.
Sebastian Redl wrote:
Pablo Aguilar wrote:
Meryl Silverburgh wrote:
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)); }
I think it's also wrong. You need to walk the index list backwards because otherwise you change the indices of the data vector and remove the wrong elements.
Sebastian Redl
Hmm... I think you missed the sort call, just before FOREACH. Pablo Aguilar