Class CircularBufferDouble

  • All Implemented Interfaces:
    CollectionDouble, CollectionNumber, ListNumber

    public class CircularBufferDouble
    extends ListDouble
    An implementation of a list on top of a circular buffer. The buffer will start at the initial capacity (default 10) and will continue to grow until the max capacity is reached. At that point, it will start to replace the oldest value with a newer one.
    Author:
    carcassi
    • Constructor Detail

      • CircularBufferDouble

        public CircularBufferDouble​(int maxCapacity)
        Creates a new circular buffer with the given maximum capacity.
        Parameters:
        maxCapacity - maximum capacity
      • CircularBufferDouble

        public CircularBufferDouble​(int initialCapacity,
                                    int maxCapacity)
        Creates a new circular buffer with the given initial and maximum capacity.
        Parameters:
        initialCapacity - initial capacity
        maxCapacity - maximum capacity
    • Method Detail

      • getDouble

        public double getDouble​(int index)
        Returns the element at the specified position in this list casted to a double.
        Parameters:
        index - position of the element to return
        Returns:
        the element at the specified position in this list
      • size

        public int size()
        Returns the number of elements in the collection.
        Returns:
        the number of elements in the collection
      • addDouble

        public void addDouble​(double value)
        Adds a new value.
        Parameters:
        value - new value
      • clear

        public void clear()
        Removes all values from the buffer.
      • getCurrentCapacity

        public int getCurrentCapacity()
        The maximum capacity for this circular buffer.
        Returns:
        maximum capacity