In article <e8d13a91-0b3b-4949-88b9-00f6088bdfa1
@[EMAIL PROTECTED]
>, stevenj@[EMAIL PROTECTED]
says...
[ ... ]
> PS. For even N, the fastest way to ****ft by N/2 is almost certainly
> just a loop of N/2 swaps in-place as another poster pointed out.
As you'd guess, that's what swap_ranges does (25.2.2/3):
Effects: For each non-negative integer n < (last1 - first1) performs:
swap(*(first1 + n), *(first2 + n))
I see little likelihood that writing the loop yourself will gain
anything.
> For
> odd N, or for an arbitrary cyclic ****ft of the array, in the past
> we've found that the fastest scheme is to do two in-place p***** over
> the array: one to reverse the order, and one to un-reverse the two
> segments before and after the ****ft.
Until or unless profiling indicated a necessity to use something else,
I'd use std::rotate. For that matter, I'm not quite sure why your
algorithm would be faster than std::rotate, though I certainly haven't
profiled it to figure out for sure.
--
Later,
Jerry.
The universe is a figment of its own imagination.


|