[wpimath] Add generic circular buffer class to Java (#5969)

The original is now called DoubleCircularBuffer.
This commit is contained in:
Tyler Veness
2023-11-30 21:12:23 -08:00
committed by GitHub
parent 9fa28eb07a
commit 0f9ebe92d9
7 changed files with 455 additions and 42 deletions

View File

@@ -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) {