Package org.epics.util.array
Class CircularBufferDouble
- java.lang.Object
-
- org.epics.util.array.ListDouble
-
- org.epics.util.array.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 Summary
Constructors Constructor Description CircularBufferDouble(int maxCapacity)
Creates a new circular buffer with the given maximum capacity.CircularBufferDouble(int initialCapacity, int maxCapacity)
Creates a new circular buffer with the given initial and maximum capacity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDouble(double value)
Adds a new value.void
clear()
Removes all values from the buffer.int
getCurrentCapacity()
The maximum capacity for this circular buffer.double
getDouble(int index)
Returns the element at the specified position in this list casted to a double.int
size()
Returns the number of elements in the collection.-
Methods inherited from class org.epics.util.array.ListDouble
equals, getByte, getFloat, getInt, getLong, getShort, hashCode, iterator, setAll, setByte, setDouble, setFloat, setInt, setLong, setShort, subList, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.epics.util.array.CollectionNumber
toArray
-
-
-
-
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 capacitymaxCapacity
- 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
-
-