|
ESPHome 2026.11.0b6
|
Fixed-capacity circular buffer - allocates once at runtime, never reallocates. More...
#include <helpers.h>
Data Structures | |
| class | ConstIterator |
| class | Iterator |
Public Member Functions | |
| FixedRingBuffer ()=default | |
| ~FixedRingBuffer () | |
| FixedRingBuffer (const FixedRingBuffer &)=delete | |
| FixedRingBuffer & | operator= (const FixedRingBuffer &)=delete |
| void | init (index_type capacity) |
| Allocate capacity - can only be called once. | |
| bool | push (const T &value) |
| Push a value. Returns false if full. | |
| void | push_overwrite (const T &value) |
| Push a value, overwriting the oldest if full. | |
| size_t | push (const T *data, size_t len) |
Push up to len values without overwriting. Returns how many fit. | |
| void | pop () |
| Remove the oldest element. | |
| size_t | pop (T *out, size_t len) |
Move up to len of the oldest values into out. Returns how many were copied. | |
| T & | front () |
| const T & | front () const |
| index_type | size () const |
| bool | empty () const |
| index_type | capacity () const |
| index_type | free_space () const |
| bool | full () const |
| void | clear () |
| Clear all elements (reset to empty, keep capacity) | |
| Iterator | begin () |
| Iterator | end () |
| ConstIterator | begin () const |
| ConstIterator | end () const |
| const T & | operator[] (index_type pos) const |
The element pos places after the oldest one; the sum is widened so a small index type cannot truncate it. | |
Protected Member Functions | |
| index_type | wrap_ (size_t index) const |
| Fold an index below 2 * capacity back into the buffer. | |
Protected Attributes | |
| T * | data_ {nullptr} |
| index_type | head_ {0} |
| index_type | tail_ {0} |
| index_type | count_ {0} |
| index_type | capacity_ {0} |
Fixed-capacity circular buffer - allocates once at runtime, never reallocates.
Runtime-sized equivalent of StaticRingBuffer - use when capacity is only known at initialization. Supports FIFO push/pop and iteration over queued elements. Not thread-safe.
|
default |
|
inline |
|
delete |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
delete |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlineprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |