|
Boost Users : |
From: Pablo Aguilar (pablo.aguilar_at_[hidden])
Date: 2006-03-03 16:31:52
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));
}
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net