A template for ring buffer implementation
Dependents: AwsomeStation LoRaBaseStation LoRaTerminal
Diff: RingBuffer.cpp
- Revision:
- 6:790344151d69
- Parent:
- 5:021f688bfdaa
- Child:
- 7:3e06927ef5ec
diff -r 021f688bfdaa -r 790344151d69 RingBuffer.cpp --- a/RingBuffer.cpp Fri Sep 02 03:23:04 2016 +0000 +++ b/RingBuffer.cpp Sat Sep 03 05:41:23 2016 +0000 @@ -100,27 +100,13 @@ template <typename T> T CircularBuffer<T>::first() { - if (read_ptr > 0) - { - return data[read_ptr - 1]; - } - else - { - return data[read_ptr]; - } + return data[read_ptr]; } template <typename T> T CircularBuffer<T>::last() { - if (write_ptr > 0) - { - return data[write_ptr - 1]; - } - else - { - return data[write_ptr]; - } + return data[write_ptr]; } template <typename T>