From: Max Motovilov (max_at_[hidden])
Date: 2008-03-17 17:33:48
> I finally looked more closely at your code and it doesn't use
> views as mine does. The reason I used views was because that
> was what the book exercise requested. On closer inspection,
> I'm guessing that your using a vector of "overflow" iterators,
> where the size of the vector is the number of domains, and
> each increment of the iterator increments the last element
> of the vector until it reaches the end, then resets that
> one and increments the previous overflow iterator in
> the vector. Is that about right?
That's correct for the "iterative" version. The "recursive" version is
modeled after your code. Without the requirement to flatten the view the
code was really simple; with this requirement most of the charm is gone
and remaining marginal improvements in simplicity certainly don't seem
to be worth the loss in performance.
> This seems pretty good to me and I don't see how the one I produced
> could beat that. I may just try it anyway just to see.
I don't think any version that has an effective recursion on the length
of the resulting sequence (as opposed to the number of domains) can do
very well. On the other hand, iterator triplets and overflow flags look
like ugly warts in the realm of functional programming ;)
Boost list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk