Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

rotate
PrevUpHomeNext
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.


PrevUpHomeNext