Package de.gsi.dataset.utils
Class DoubleRingBuffer
- java.lang.Object
-
- de.gsi.dataset.utils.DoubleRingBuffer
-
public class DoubleRingBuffer extends java.lang.Objectsimple circular ring buffer implementation for double type (with read/write position)- Author:
- rstein
-
-
Constructor Summary
Constructors Constructor Description DoubleRingBuffer(int capacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()booleanput(double element)intput(double[] newElements, int length)intremainingCapacity()voidreset()resets and clears bufferdoubletake()inttake(double[] into, int length)
-
-
-
Method Detail
-
reset
public void reset()
resets and clears buffer
-
available
public int available()
- Returns:
- number of available buffer elements
-
remainingCapacity
public int remainingCapacity()
- Returns:
- number of elements that can be written before buffer wraps-around
-
put
public boolean put(double element)
- Parameters:
element- new element- Returns:
- true: read index is above write index
-
put
public int put(double[] newElements, int length)- Parameters:
newElements- new elements to be addedlength- number of elements to be added- Returns:
- number of elements added
-
take
public double take()
- Returns:
- element at head of buffer
-
take
public int take(double[] into, int length)- Parameters:
into- storage containerlength- how many elements are to be retrieved- Returns:
- n elements at the head of the buffer
-
-