Files CCore/inc/algon/SimpleRotate.h CCore/src/algon/SimpleRotate.cpp
Two simple range rotation algorithms are presented here.
template <class R> void Algon::RangeRotateLeft(R r) { SimpleRotateAlgo<R>::RotateLeft(r); } /* RangeRotateRight() */ template <class R> void Algon::RangeRotateRight(R r) { SimpleRotateAlgo<R>::RotateRight(r); } /* struct SimpleRotateAlgo<R,Algo> */ template <class R,class Algo=Algon::BaseRangeAlgo<R> > struct Algon::SimpleRotateAlgo : Algo { using Algo::GetLen; using Algo::Reverse; static void RotateLeft(R r) { for(; GetLen(r)>1 ;++r) Swap(r[0],r[1]); } static void RotateRight(R r) { RangeRotateLeft(Reverse(r)); } };
RangeRotateLeft() and RangeRotateRight() permutate the elements of the given range. RangeRotateLeft() rotates them by the one element left, RangeRotateRight() rotates them by the one element right.
SimpleRotateAlgo is an Algorithm Package with the two rotation algorithms.