my problem is pretty simple, I am using an eye tracking device, which sends gaze position every 30ms approximately. So, every 30ms, a variable smoothedCoordinates
is updated.
I would like to determine, using the last X (10 for example) values of smoothedCoordinates
, a zone on the screen where the user is looking at.
To do this I have to store these values of smoothedCoordinates
in a container and do a process on it to determine the zone (by getting the xmin, xmax, ymin ,ymax of these X values)
.
I thought about using a FIFO, each time the variable is updated I would push the value to the front of the fifo and pop the back one, in this case my FIFO would always be the same size.
But is it possible to accede directly to all the elements of a FIFO, without popping them ? I searched the internet and it looks like it's only possible to accede to the first element and the last one ?
.
If it isn't possible to do it with a FIFO, is there another container that would suit my needs ?
You could just use a standard array and give it FIFO like capabilities like the following
char array[20];
// prepend the array and cut off the last value
for (int i = 19 ; i >= 0 ; i--)
{
// ignore the last element, so it gets overwritten
if (i != 19) array[i+1] = array[i];
}
// add the new value to the array at the now available 1st index
array[0] = firstElement[0];