|
Boost : |
Subject: Re: [boost] combinations and permutations
From: Howard Hinnant (howard.hinnant_at_[hidden])
Date: 2011-01-05 09:38:30
On Jan 5, 2011, at 4:41 AM, Mathias Gaunard wrote:
> On 04/01/2011 16:03, Howard Hinnant wrote:
>
>>> I need to read this through thoroughly (it looks interesting), but along the same vein, an alternative abstraction is to create a range adaptor that allows iteration through permutations and combinations of a given range. This would be more flexible than a for_each algorithm style of iteration, but possibly less efficient.
>>
>> I'm not positive but I suspect that a range adaptor approach would suffer precisely the same inefficiencies I've demonstrated in the next_permutation/combination algorithms: The increment operator begins to dominate as shown in the two figures. That being said, the two approaches do not have to compete. They can coexist.
>
> You could generate the range adaptor from the for_each-style algorithm using a coroutine ; this should have minimal overhead.
I looked at:
http://en.wikipedia.org/wiki/Coroutine
and was unsuccessful in translating that idea to this application. Perhaps you could elaborate?
-Howard
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk