I want to develop a program that will constantly calculate an average from 1000 elements (this is not the question). The problem is this:
Something like private double[] collection = new double[1000];
.
The program is event driven and there are times new elements have to be put to the array. When a new one is put, the very first is removed, so I have to shuffle all elements which will slow me down.
Is there a ready structure like Queue, which can pop the first element and add a new one at the last position, and a structure that I can read all elements from 0-th to the 1000 element [and speed is of the essence, because there will be times when this a new element will be added 10-20 times a second]?
The highest NET framework I can use is 3.5, so there is no ConcurrentQueue available there. And I want to go through each element upon dequeueing and enqueueing an item, because I need to do some calculations with them.