#include <circular_buffer.h>
|
bool | empty () const |
|
bool | full () const |
|
void | reset () |
| Reset the circular buffer to empty.
|
|
bool | push (T elem) |
|
T | front () const |
|
bool | pop (T &elem) |
|
index_t | count () const |
|
template<typename T = uint8_t, typename index_t = uint_fast8_t, size_t size = 16>
class CircularBuffer< T, index_t, size >
A generic circular buffer class Can hold up to size elements
- Parameters
-
T | data type of stored elements |
index_t | data type of indices into array of elements (recommended to keep uint8_fast8_t as single byte operations are atomical on the AVR) |
size | number of elements to store It is recommended to keep a power of 2 to allow for optimal code generation on the AVR (there is no HW modulo instruction) |
◆ front()
template<typename T = uint8_t, typename index_t = uint_fast8_t, size_t size = 16>
- Returns
- peeks the current element to extract from the buffer, however the element is left in the buffer Does not perform any range checks for performance reasons, should be preceeded by if(!empty()) in the user code
◆ pop()
template<typename T = uint8_t, typename index_t = uint_fast8_t, size_t size = 16>
Extracts the current element from the buffer
- Returns
- true in case there was an element for extraction (i.e. the buffer was not empty)
◆ push()
template<typename T = uint8_t, typename index_t = uint_fast8_t, size_t size = 16>
Insert an element into the buffer. Checks for empty spot for the element and does not change the buffer content in case the buffer is full.
- Returns
- true if the insertion was successful (i.e. there was an empty spot for the element)
The documentation for this class was generated from the following file: