|
Boost Users : |
Subject: [Boost-users] for_each_until like algorithm
From: Peter Barker (newbarker_at_[hidden])
Date: 2009-02-11 07:06:20
Hi,
I just wondered if there was already an algorithm (or way to compose
one) in Boost that would allow me to iterate over a container of
pointers to objects calling a function on each one and completing when
one of them returned a particular value?
For example, I have a master/child relationship and the master has a
method called shouldCalculate(). Whether this returns true is partly
dependent on what the children return for their shouldCalculate()
method. So I'd like to say something like this:
bool Master::shouldCalculate()
{
// Look at data at the master level to see if it's stale. If it
is, return true.
// See if any of the children should calculate
bool staleChildren =
boost::for_each_until(children_.begin(),children_.end(),
boost::bind(&Child::shouldCalculate,_1),until_true_returned);
return staleChildren;
}
Regards,
Pete
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