Small library for using circular buffers (forked from François Berder's implementation in order to add methods and fix problems)
Dependents: CircularBufferTest XBeeApi
Fork of CircularBuffer by
Test suite can be found in this application, CircularBufferTest
Diff: CircularBuffer.h
- Revision:
- 6:242d0e9f13d1
- Parent:
- 5:abe8909f9603
- Child:
- 7:e2d532183250
--- a/CircularBuffer.h Sat Jan 18 17:56:32 2014 +0000 +++ b/CircularBuffer.h Sat Jan 18 18:01:03 2014 +0000 @@ -83,7 +83,7 @@ template<size_t T> CircularBuffer<T>::CircularBuffer(): -readIndex(T), +readIndex(0), writeIndex(0) { } @@ -141,7 +141,7 @@ template<size_t T> uint32_t CircularBuffer<T>::getSize() const { - return ((writeIndex > readIndex) ? (writeIndex - readIndex) : (T + writeIndex - readIndex)); + return ((writeIndex >= readIndex) ? (writeIndex - readIndex) : (T + writeIndex - readIndex)); } template<size_t T>