Boost logo

Boost Users :

From: Meryl Silverburgh (silverburgh.meryl_at_[hidden])
Date: 2007-02-02 15:05:44


Hi,

I have a sorted int vector 'orgWidth'. I would like to save the save
into a new int vector 'newWidth' if the value of the current element
is 10% bigger than the previous one.

For example,
orgWidth int vector : 300 366 729 769 781 1297
newWidth int vector: 300 366 729 1297

I know how to add the value to the newWidth vector using the if_then
with boost. But my question is how can I update the value of the
'previousWidth' as I use for_each() algorithm.

int previousWidth = -1;
vector<int> orgWidth;
                        

for_each(orgWidth.begin(), orgWidth.end(), if_then( (_1 >
(previousWidth * 1.1)) , bind
(&vector<int>::push_back,boost::ref(newWidth), _1 )));

Thanks for any help.


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