Let's say I have a sequence of integers, from 0 (always starting at 0) to 3. Now, I have an array of integers, which will hold those sequence looped one after the other, starting from a certain point. For example:
An array of 10 elements, the sequence is 0 to 3, and start at 2, should yield 2, 3, 0, 1, 2, 3, 0, 1, 2, 3.
An array of 5 elements, the sequence 0 to 5, and start at 5, should yield 5, 0, 1, 2, 3.
An array of 5 elements, the sequence 0 to 10, and start at 3, should yield 3, 4, 5, 6, 7.
I'm suffering brain freeze! What's the best way to create this array if you know the array size, max number in sequence, and starting value?
My best attempt was:
private static int[] CreateIndexers(int index, int size, int players)
{
var indexers = new int[size];
for (int i = 0; i < size; i++)
{
var division = i / players;
var newInt = division + i >= players ? ((division + i) - players) : division + i;
indexers[i] = newInt;
}
return indexers;
}