#include <circular_buffer.h>
|
static constexpr bool | size_is_power2 = !(size & (size - 1)) |
|
|
static index_t | mask (index_t cursor) |
|
static index_t | next (index_t cursor) |
|
|
index_t | tail |
| cursor of the element to read (pop/extract) from the buffer
|
|
index_t | head |
| cursor of the empty spot or element insertion (write)
|
|
template<typename index_t = uint_fast8_t, index_t size = 16>
class CircularIndex< index_t, size >
A generic circular index class which can be used to build circular buffers Can hold up to size elements
- Parameters
-
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 index positions. It is recommended to keep a power of 2 to allow for optimal code generation on the AVR (there is no HW modulo instruction) |
◆ back()
template<typename index_t = uint_fast8_t, index_t size = 16>
- Returns
- return the head index from the buffer. Does not perform any range checks for performance reasons, should be preceeded by if(!empty()) in the user code
◆ count()
template<typename index_t = uint_fast8_t, index_t size = 16>
- Returns
- number of elements in the buffer
◆ empty()
template<typename index_t = uint_fast8_t, index_t size = 16>
◆ front()
template<typename index_t = uint_fast8_t, index_t size = 16>
- Returns
- return the tail index from the buffer. Does not perform any range checks for performance reasons, should be preceeded by if(!empty()) in the user code
◆ full()
template<typename index_t = uint_fast8_t, index_t size = 16>
◆ mask()
template<typename index_t = uint_fast8_t, index_t size = 16>
static index_t CircularIndex< index_t, size >::mask |
( |
index_t |
cursor | ) |
|
|
inlinestaticprotected |
- Returns
- the index position given a cursor
◆ next()
template<typename index_t = uint_fast8_t, index_t size = 16>
static index_t CircularIndex< index_t, size >::next |
( |
index_t |
cursor | ) |
|
|
inlinestaticprotected |
- Returns
- next cursor for internal comparisons
◆ pop()
template<typename index_t = uint_fast8_t, index_t size = 16>
Advance the tail index from the buffer. No checks are performed. empty() needs to be queried beforehand.
◆ push()
template<typename index_t = uint_fast8_t, index_t size = 16>
Advance the head index of the buffer. No checks are performed. full() needs to be queried beforehand.
The documentation for this class was generated from the following file: