I would like to know what kind of data structure (queue) I should use if I have the following problem:
- The queue must have a dynamically assigned length (say, 512).
- Every new value is saved at the end of the queue.
- When a new value is added, the first is dropped if the queue is already full. If I add 30 new values to a full queue, the 30 first are automatically dropped.
- The kind of data stored be arrays or some other simple object.
- I need to be able to quickly retrieve the values using a loop, always in order (no random access).
The purpose of this is to have a fixed width data source that a graph will scan to draw its curve.
EDIT: This graph is meant to be shown on an Android custom View. Is there a specific length I could use that would make the looping thru this faster?
EDIT2: Added "When a new value is added, the first is dropped if the queue is already full. If I add 30 new values to a full queue, the 30 first are automatically dropped."