| Home | Libraries | People | FAQ | More

##### rotate

###### Prototype

    template<class ForwardRange>
    ForwardRange& rotate(ForwardRange& rng,
                         typename range_iterator<ForwardRange>::type middle);

    template<class ForwardRange>
    const ForwardRange& rotate(const ForwardRange& rng,
                               typename range_iterator<const ForwardRange>::type middle);

###### Description

`rotate` rotates the elements in a range. It exchanges the two ranges `[begin(rng), middle)` and `[middle, end(rng))`. Returns a reference to `rng`.

###### Definition

Defined in the header file `boost/range/algorithm/rotate.hpp`

###### Requirements

- `ForwardRange` is a model of the Forward Range Concept.
- `ForwardRange` is mutable.

###### Precondition:

- `[begin(rng), middle)` is a valid range.
- `[middle, end(rng))` is a valid range.

###### Complexity

Linear. At most `distance(rng)` swaps are performed.