mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
[wpimath] Add generic circular buffer class to Java (#5969)
The original is now called DoubleCircularBuffer.
This commit is contained in:
@@ -268,16 +268,18 @@ class circular_buffer {
|
||||
size_t m_length = 0;
|
||||
|
||||
/**
|
||||
* Increment an index modulo the length of the buffer.
|
||||
* Increment an index modulo the size of the buffer.
|
||||
*
|
||||
* @return The result of the modulo operation.
|
||||
* @param index Index into the buffer.
|
||||
* @return The incremented index.
|
||||
*/
|
||||
size_t ModuloInc(size_t index) { return (index + 1) % m_data.size(); }
|
||||
|
||||
/**
|
||||
* Decrement an index modulo the length of the buffer.
|
||||
* Decrement an index modulo the size of the buffer.
|
||||
*
|
||||
* @return The result of the modulo operation.
|
||||
* @param index Index into the buffer.
|
||||
* @return The decremented index.
|
||||
*/
|
||||
size_t ModuloDec(size_t index) {
|
||||
if (index == 0) {
|
||||
|
||||
Reference in New Issue
Block a user