diff --git a/wpilibc/shared/include/CircularBuffer.inc b/wpilibc/shared/include/CircularBuffer.inc index c42dea8e8c..200d556265 100644 --- a/wpilibc/shared/include/CircularBuffer.inc +++ b/wpilibc/shared/include/CircularBuffer.inc @@ -79,6 +79,9 @@ T CircularBuffer::PopBack() { return m_data[(m_front + m_length) % m_data.size()]; } +/** + * Sets internal buffer contents to zero. + */ template void CircularBuffer::Reset() { std::fill(m_data.begin(), m_data.end(), 0); @@ -87,7 +90,7 @@ void CircularBuffer::Reset() { } /** - * Returns element at index starting from front of buffer. + * @return Element at index starting from front of buffer. */ template T& CircularBuffer::operator[](size_t index) { @@ -95,7 +98,7 @@ T& CircularBuffer::operator[](size_t index) { } /** - * Returns element at index starting from front of buffer. + * @return Element at index starting from front of buffer. */ template const T& CircularBuffer::operator[](size_t index) const { @@ -103,7 +106,9 @@ const T& CircularBuffer::operator[](size_t index) const { } /** - * Increment an index modulo the length of the m_data buffer + * Increment an index modulo the length of the buffer. + * + * @return The result of the modulo operation. */ template size_t CircularBuffer::ModuloInc(size_t index) { @@ -111,7 +116,9 @@ size_t CircularBuffer::ModuloInc(size_t index) { } /** - * Decrement an index modulo the length of the m_data buffer + * Decrement an index modulo the length of the buffer. + * + * @return The result of the modulo operation. */ template size_t CircularBuffer::ModuloDec(size_t index) { diff --git a/wpilibcIntegrationTests/src/CircularBufferTest.cpp b/wpilibcIntegrationTests/src/CircularBufferTest.cpp index 80a5ccd304..c387c32552 100644 --- a/wpilibcIntegrationTests/src/CircularBufferTest.cpp +++ b/wpilibcIntegrationTests/src/CircularBufferTest.cpp @@ -28,7 +28,7 @@ TEST(CircularBufferTest, PushFrontTest) { queue.PushFront(value); } - for (unsigned int i = 0; i < pushFrontOut.size(); i++) { + for (size_t i = 0; i < pushFrontOut.size(); i++) { EXPECT_EQ(pushFrontOut[i], queue[i]); } } @@ -40,7 +40,7 @@ TEST(CircularBufferTest, PushBackTest) { queue.PushBack(value); } - for (unsigned int i = 0; i < pushBackOut.size(); i++) { + for (size_t i = 0; i < pushBackOut.size(); i++) { EXPECT_EQ(pushBackOut[i], queue[i]); } } diff --git a/wpilibj/src/shared/java/edu/wpi/first/wpilibj/CircularBuffer.java b/wpilibj/src/shared/java/edu/wpi/first/wpilibj/CircularBuffer.java index 6a10c81bd9..31e6626886 100644 --- a/wpilibj/src/shared/java/edu/wpi/first/wpilibj/CircularBuffer.java +++ b/wpilibj/src/shared/java/edu/wpi/first/wpilibj/CircularBuffer.java @@ -12,10 +12,16 @@ package edu.wpi.first.wpilibj; */ public class CircularBuffer { private double[] m_data; + + // Index of element at front of buffer private int m_front = 0; + + // Number of elements used in buffer private int m_length = 0; - @SuppressWarnings("JavadocMethod") + /** + * @param size The size of the circular buffer. + */ public CircularBuffer(int size) { m_data = new double[size]; for (int i = 0; i < m_data.length; i++) { @@ -91,7 +97,9 @@ public class CircularBuffer { return m_data[(m_front + m_length) % m_data.length]; } - @SuppressWarnings("JavadocMethod") + /** + * Sets internal buffer contents to zero. + */ public void reset() { for (double i : m_data) { i = 0.0; @@ -101,7 +109,7 @@ public class CircularBuffer { } /** - * @return element at index starting from front of buffer. + * @return Element at index starting from front of buffer. */ public double get(int index) { return m_data[(m_front + index) % m_data.length]; diff --git a/wpilibj/src/test/java/edu/wpi/first/wpilibj/CircularBufferTest.java b/wpilibj/src/test/java/edu/wpi/first/wpilibj/CircularBufferTest.java index ecd95b436c..b93b2443ba 100644 --- a/wpilibj/src/test/java/edu/wpi/first/wpilibj/CircularBufferTest.java +++ b/wpilibj/src/test/java/edu/wpi/first/wpilibj/CircularBufferTest.java @@ -94,5 +94,4 @@ public class CircularBufferTest { // Leaving only one element with value == 4 assertEquals(4.0, queue.get(0), 0.00005); } - }