Boost logo

Boost :

Subject: Re: [boost] [algorithm] adjacent_for_each interest?
From: Ian Hobson (ian.r.hobson_at_[hidden])
Date: 2013-02-17 09:57:04


I've updated the implementation with support for input iterators.

I think it makes a nice companion to adjacent_find so I'll leave it operating on element pairs for now. I like the idea of also adding adjacent_transform.

I would be very interested in an adaptor for boost.range for general windowing tasks, with parameters for window size and hop size.

Best,
Ian

On 12 Feb 2013, at 14:24, Thorsten Ottosen <thorsten.ottosen_at_[hidden]> wrote:

> On 10-02-2013 14:10, Ian Hobson wrote:
>> Hi,
>>
>> Is there any interest in a version of for_each that operates on each adjacent pair of elements in a range?
>>
>> #include <iostream>
>> #include <boost/algorithm/adjacent_for_each.hpp>
>>
>> void PrintInts(int a, int b) {
>> std::cout << '(' << a << ", " << b << ")\n";
>> }
>>
>> int main() {
>> const int ints[] = {0, 1, 2, 3, 4};
>> boost::algorithm::adjacent_for_each(ints, ints + 5, PrintInts);
>> }
>
> Yes, I think would be a good utillity. But consider generalizing:
>
> for_each_slice<N>( ..., PrintInts() )
>
> so we can decide how big the sliding window is. Perhaps it's better with a run-time argument:
>
> for_each_slice( 3, // size of slize
> iterator begin,
> iterator end,
> Functor fun )
>
> and provide range overload in terms of the iterator version.
>
> -Thorsten
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


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