Boost logo

Boost Users :

From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2006-03-03 17:33:00


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


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