Subject: Re: [boost] AlRangeExandrescu?
From: Maxim Yanchenko (maximyanchenko_at_[hidden])
Date: 2009-07-27 07:39:27
David Abrahams <dave <at> boostpro.com> writes:
> >>> Then how would you safely implement
> >>> find[_f-1,_e]( range, x );
> >> At first glance, you can't. Is there a known use case for that? If not,
> > Who knows. Maybe you want the element before the found one to be there for
> "Maybe, for some reason" arguments don't hold much water with me,
> especially in a library design context.
Say I have an array of prices active now on exchange.
In my algorithm, I come up with some price, and now I want to place my orders 5
levels above and 5 levels below the price I need.
With iterators (omitting boundary cases) this would be:
it = find( prices.begin(), prices.end(), desired_price );
desired_levels = boost::range( it-5, it+5 );
place_orders( desired_levels );
With the syntax above, what I need is find[_f-5, _f+5](range, x).
There can be more examples if this kind, say fancy smoothing an image, when you
need to find a pixel and then smooth it over neighbor pixels.
Same in numerical calculations on grids - you often take neighbors of what you
found into account.
Maxim (to reply in private, use FirstName.LastName_at_[hidden])