Boost logo

Boost :

Subject: Re: [boost] [algorithm] adjacent_for_each interest?
From: Akira Takahashi (faithandbrave_at_[hidden])
Date: 2013-02-11 20:17:56


Hi,

2013/2/11 Nathan Ridge <zeratul976_at_[hidden]>

>
> > > Is there any interest in a version of for_each that operates on each
> adjacent pair of elements in a range?
> > [...]
> >
> > P.S. Consider implementation of companion - transform_adjacent.
> > Maybe even consider version which accepts "count of adjacent elements
> > within each iteration" as template non-type parameter.
> > Or maybe choose some another approach involving Boost.Range?
>
> I think a more general approach would be a Boost.Range-style range
> adaptor [1] that presents a view of the range where elements in
> the view are pairs of (references to, if desired) elements in the
> underlying range. You can then use standard algorithms like for_each
> and transform on the adapted range.
>
> I have written such an adaptor in the past and called it
> 'adjacent_paired'. I've also seen (can't remember where) the name
> 'windowed' used for the more general version which presents a view
> of tuples of N adjacent elements.
>
> Regards,
> Nate
>
> [1]
> http://www.boost.org/doc/libs/1_53_0/libs/range/doc/html/range/reference/adaptors/introduction.html
>
>
Agree.
I have range-adaptor implementation already.
Please see:

http://dl.dropbox.com/u/1682460/git/OvenToBoost/libs/range/doc/html/range_extension/reference/range_adaptors/adjacent_zipped.html
https://github.com/faithandbrave/OvenToBoost/blob/master/boost/range/adaptor/adjacent_zipped.hpp

>>========================
Akira Takahashi
mailto:faithandbrave_at_[hidden]
site: https://sites.google.com/site/faithandbrave/about/en


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk