$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
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