Boost logo

Boost Users :

From: Pablo Aguilar (pablo.aguilar_at_[hidden])
Date: 2006-03-03 18:55:46


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


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