EuclidRotate

Files CCore/inc/algon/EuclidRotate.h CCore/src/algon/EuclidRotate.cpp

EuclidRotateAlgo is an Algorithm Package. It is parametrized by a generalized range type and contains range rotation algorithms. The second template parameter is defaulted to BaseRangeAlgo<R>.


template <class R,class Algo=Algon::BaseRangeAlgo<R> >
struct Algon::EuclidRotateAlgo : Algo
 {
  static void Rotate(R r,LenType prefix,LenType suffix); // prefix+suffix == GetLen(r)
  
  static void Rotate_prefix(R r,LenType prefix); // prefix <= GetLen(r)
  
  static void Rotate_suffix(R r,LenType suffix); // suffix <= GetLen(r)
 };

Rotate() rotates the range. Rotation is a permutation of range elements, it can be considered as the swapping two subranges: prefix and suffix. prefix is the prefix length, suffix is the suffix length. Permutation is performed by the swapping elements.

Rotate_prefix() rotates the range, prefix is the prefix length. It is a rotation left by prefix elements.

Rotate_suffix() rotates the range, suffix is the suffix length. It is a rotation right by suffix elements.

There is a family of functions for the range rotation.


template <class R,class Len>
void Algon::EuclidRotate_prefix(R r,Len prefix) { Algon::EuclidRotateAlgo<R>::Rotate_prefix(r,prefix); }

template <class R,class Len>
void Algon::EuclidRotate_suffix(R r,Len suffix) { Algon::EuclidRotateAlgo<R>::Rotate_suffix(r,suffix); }

They call the correspondent rotate algorithms from the EuclidRotateAlgo.