DoubleQueue
A fixed-size queue specifically designed to store double values. This class implements a simple queue where new elements are added to the front, and existing elements shift towards the back, with the oldest element being removed if the queue is at its maximum capacity.
Methods
DoubleQueue(double[] data)
Constructs a DoubleQueue using an existing double array. The size of the queue will be determined by the length of the provided array.
DoubleQueue(int size)
Constructs a new DoubleQueue with a specified size. The internal array will be initialized to this size.
get(int index)
Retrieves the double value at the specified index in the queue. Index 0 represents the most recently added element.
getData()
Returns a new array containing the current elements of the queue. The returned array's length will be equal to the number of elements currently in the queue.
add(double value)
Adds a new double value to the front of the queue. Existing elements are shifted one position back. If the queue is full, the oldest element is removed.
set(int index, double value)
Sets the double value at the specified index in the queue. This method directly modifies an existing element.
clear()
Clears all elements from the queue, setting all values to 0 and resetting the internal index.