Java keep track of highest and lowest values in a window of constant values
I have an audio input stream which calculates what the current volume is.
over a certain windows size (which can range from 5 to 40), I want to keep
track of the highest and lowest values inside the window.
so say if i ran the program for 8 iterations with a window of 5 and this
would result. with only the low and high values being of importance
add 2
2
add 4
2 4
add 3
2 3 4
add 2
2 2 3 4
add 7
2 2 3 4 7
-first 2 removed from list add 9
2 3 4 7 9
4 removed , add 5
2 3 5 7 9
3 removed , add 2
2 2 5 7 9
etc
what would be the most efficient way to do this and using what type of
collections
No comments:
Post a Comment