Is there something that will make it possible in C#
create array for example int[6,10]
.
And always when i add new element [i,0]
all elements in this row will shifted +1
. And last will remove.
Now I had to do something like this:
array[i, 2] = array[i, 1];
array[i, 1] = array[i, 0];
array[i, 0] = value;
Could it be better to use for example dictionary with int and List?
Edit: I not only move this data i will use this data to calculate something. So I think Queue wont be good for this.
I need it for method like this. In this method i do it only for array[6,2]. Now i think i need know more about my history. So i will have array[6,10]. I will check diferent cases and created dependencies. I need something to that it would look as clear as possible and work quickly.
public static double CalculateLastValue(double value, KalmanModel k, int i)
{
if (k.LastDistance[i, 0] == 0 && k.LastDistance[i, 1]==0)
{
k.LastDistance[i, 0] = value;
k.LastDistance[i, 1] = value;
}
if (k.LastDistance[i, 0] == k.LastDistance[i, 1])
{
if (Math.Abs(value - k.LastDistance[i, 0]) > 2 && value < k.LastDistance[i, 0])
{
value = k.LastDistance[i, 0] - 2;
}
else if (Math.Abs(value - k.LastDistance[i, 0]) > 2 && value > k.LastDistance[i, 0])
{
value = k.LastDistance[i, 0] + 2;
}
k.LastDistance[i, 1] = k.LastDistance[i, 0];
k.LastDistance[i, 0] = value;
return value;
}
else if (k.LastDistance[i, 0] > k.LastDistance[i, 1])
{
if (value >= k.LastDistance[i, 0])
{
if (Math.Abs(value - k.LastDistance[i, 0]) > 2)
{
value = k.LastDistance[i, 0] + 2;
}
k.LastDistance[i, 1] = k.LastDistance[i, 0];
k.LastDistance[i, 0] = value;
return value;
}
else
{
value = k.LastDistance[i, 0];
k.LastDistance[i, 1] = k.LastDistance[i, 0];
return value;
}
}
else
{
if (value <= k.LastDistance[i, 0])
{
if (Math.Abs(value - k.LastDistance[i, 0]) > 2)
{
value = k.LastDistance[i, 0] - 2;
}
k.LastDistance[i, 1] = k.LastDistance[i, 0];
k.LastDistance[i, 0] = value;
return value;
}
else
{
value = k.LastDistance[i, 0];
k.LastDistance[i, 1] = k.LastDistance[i, 0];
return value;
}
}
}