So I am not sure how to describe this problem but I try my best. This problem is more or less language independent but I search for a solution in C++.
I want to create a data structure with an underlying array, where I can access the values in the array by increasing indices. After I reached the array size the indexing should decrease. I think an example will help here:
std::array<int, 3> A {-1, 9, 100}; //example values
A[-1] = "Error" => assert is ok
A[0] == -1;
A[1] == 9;
A[2] == 100; // highest possible index
A[3] == A[1] == 9;
A[4] == A[0] == -1;
A[5] = "Error" => assert is ok
So you see, I want to access value in the array up to index size() + size() - 1
. I need this for any array size. Is there any data structure in C++ or mathematic formula (I can't think of any) to calculate the correct index?
Another example if it is not clear:
std::array<int, 4> A {-1, 9, 100, 0}; //example values
A[-1] = "Error" => assert is ok
A[0] == -1;
A[1] == 9;
A[2] == 100;
A[3] == 0; // highest possible index
A[4] == A[2] == 100;
A[5] == A[1] == 9;
A[6] == A[0] == -1;
A[7] = "Error" => assert is ok