Class DoubleCircularBuffer
java.lang.Object
org.wpilib.util.container.DoubleCircularBuffer
This is a simple circular buffer so we don't need to "bucket brigade" copy old values.
-
Constructor Summary
ConstructorsConstructorDescriptionDoubleCircularBuffer(int size) Create a CircularBuffer with the provided size. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFirst(double value) Push new value onto front of the buffer.voidaddLast(double value) Push new value onto back of the buffer.voidclear()Sets internal buffer contents to zero.doubleget(int index) Get the element at the provided index relative to the start of the buffer.doublegetFirst()Get value at front of buffer.doublegetLast()Get value at back of buffer.doublePop value at front of buffer.doublePop value at back of buffer.voidresize(int size) Resizes internal buffer to given size.intsize()Returns number of elements in buffer.
-
Constructor Details
-
DoubleCircularBuffer
Create a CircularBuffer with the provided size.- Parameters:
size- The size of the circular buffer.
-
-
Method Details
-
size
-
getFirst
-
getLast
-
addFirst
Push new value onto front of the buffer. The value at the back is overwritten if the buffer is full.- Parameters:
value- The value to push.
-
addLast
Push new value onto back of the buffer. The value at the front is overwritten if the buffer is full.- Parameters:
value- The value to push.
-
removeFirst
-
removeLast
-
resize
Resizes internal buffer to given size.A new buffer is allocated because arrays are not resizable.
- Parameters:
size- New buffer size.
-
clear
Sets internal buffer contents to zero. -
get
Get the element at the provided index relative to the start of the buffer.- Parameters:
index- Index into the buffer.- Returns:
- Element at index starting from front of buffer.
-