Greetings.

I'm trying to tackle a need to get the Max and Min value of the last x elements of an array as quickly as possible.

I can do this without problem, simply checking the values of the last x elements and seeing if it is the highest or lowest value.

However, after I do this and get the results, I need to then go to the next element in the array and start the whole process all over again. This just seems like a whole lot of wasted cpu cycles.

For example:

Suppose you have an array of type Single values from 1 to 100.

fValues(1 to 100)

Suppose I want to get the Max and Min values of 6 elements at a time, starting from fValues(1) to fValues(6), then fValues(2) to fValues(7), then fValues(3) to fValues(8)... all the way to fValues(95) to fValues(100).

In other words, after each calculation, I drop the oldest (6 elements ago) and add the next element of the array to the calculation.

Is there a faster way to do this other than to do a Loop on every 6 elements? It's important as the results will be displayed graphically as a line and redraw would be an issue if there was too long a wait.

Any ideas, tips, etc?

Thank you.