Proposal: Implement a rotate algorithm, equivalent to std::rotate() in C++

This is a really important algorithm, with applications even in GUI programming (see slide <Top 5 Beautiful C++ std Algorithms Examples - C++ Stories; and gather <Top 5 Beautiful C++ std Algorithms Examples - C++ Stories), so I'm really happy someone is taking it on. You'll need different implementations depending on the index's protocol conformance <c++ - Why is std::rotate so fast? - Stack Overflow. C++ implementations can get pretty sophisticated <http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?view=markup&pathrev=251836&gt;\. Would you like additional thoughts (and if so, of what nature), or will those do? ;-)

-Dave

···

On Dec 13, 2015, at 2:20 AM, Sergey Bolshedvorsky via swift-evolution <swift-evolution@swift.org> wrote:

Hi everyone,

I’ve selected a ticket SR-125 as my first task (https://bugs.swift.org/browse/SR-125\).

I would like to propose an implementation of this method in Swift stdlib.

std::rotate() method performs a left rotation on a range of elements.
C++ declaration is void rotate (ForwardIterator first, ForwardIterator middle, ForwardIterator last)
Specifically, it swaps the elements in the range [first, last) in such a way that the element middle becomes the first element of the new range and middle - 1 becomes the last element.
A precondition of this function is that [first, n_first) and [middle, last) are valid ranges.

What are your thoughts?