3#include <Core/RaCore.hpp>
9class RA_CORE_API CircularIndex
13 CircularIndex(
const size_t size = 1,
const size_t i = 0 );
14 CircularIndex(
const CircularIndex& index );
20 inline size_t size()
const;
21 inline void setSize(
const size_t size );
24 inline size_t value()
const;
25 inline void setValue(
const size_t i );
28 inline operator size_t();
29 inline CircularIndex& operator=(
const CircularIndex&
id );
30 inline CircularIndex& operator=(
const size_t i );
31 inline CircularIndex& operator++();
32 inline CircularIndex& operator--();
33 inline CircularIndex operator+(
const int off );
34 inline CircularIndex operator-(
const int off );
35 inline bool operator==(
const CircularIndex&
id )
const;
36 inline bool operator<(
const CircularIndex&
id )
const;
37 inline bool operator==(
const size_t i )
const;
38 inline bool operator<(
const size_t i )
const;
47inline size_t CircularIndex::size()
const {
51inline void CircularIndex::setSize(
const size_t size ) {
56inline size_t CircularIndex::value()
const {
60inline void CircularIndex::setValue(
const size_t i ) {
62 idx = ( n + ( i % n ) ) % n;
66inline CircularIndex::operator size_t() {
70inline CircularIndex& CircularIndex::operator=(
const CircularIndex&
id ) {
76inline CircularIndex& CircularIndex::operator=(
const size_t i ) {
81inline CircularIndex& CircularIndex::operator++() {
86inline CircularIndex& CircularIndex::operator--() {
91inline CircularIndex CircularIndex::operator+(
const int off ) {
92 return CircularIndex( N, idx +
size_t(
int( N ) + off %
int( N ) ) );
95inline CircularIndex CircularIndex::operator-(
const int off ) {
96 return ( *
this + ( -off ) );
99inline bool CircularIndex::operator==(
const CircularIndex&
id )
const {
100 return ( idx ==
id.idx );
103inline bool CircularIndex::operator<(
const CircularIndex&
id )
const {
104 return ( idx <
id.idx );
107inline bool CircularIndex::operator==(
const size_t i )
const {
108 return ( idx == CircularIndex( N, i ) );
111inline bool CircularIndex::operator<(
const size_t i )
const {
112 return ( idx <
size_t( CircularIndex( N, i ) ) );
hepler function to manage enum as underlying types in VariableSet