ESPHome 2026.3.0
Loading...
Searching...
No Matches
esphome::StaticRingBuffer< T, N > Class Template Reference

Fixed-size circular buffer with FIFO semantics and iteration support. More...

#include <helpers.h>

Data Structures

class  ConstIterator
 
class  Iterator
 

Public Member Functions

bool push (const T &value)
 
void pop ()
 
T & front ()
 
const T & front () const
 
index_type size () const
 
bool empty () const
 
Iterator begin ()
 
Iterator end ()
 
ConstIterator begin () const
 
ConstIterator end () const
 

Protected Attributes

data_ [N]
 
index_type head_ {0}
 
index_type tail_ {0}
 
index_type count_ {0}
 

Detailed Description

template<typename T, size_t N>
class esphome::StaticRingBuffer< T, N >

Fixed-size circular buffer with FIFO semantics and iteration support.

A tiny ring buffer that avoids dynamic allocations from std::deque/std::queue (which can be wasteful on MCUs), while supporting iteration over queued elements.

Not thread-safe. All access (push/pop/iteration) must occur from a single context, or the caller must provide external synchronization.

Definition at line 303 of file helpers.h.

Member Function Documentation

◆ begin() [1/2]

template<typename T , size_t N>
Iterator esphome::StaticRingBuffer< T, N >::begin ( )
inline

Definition at line 359 of file helpers.h.

◆ begin() [2/2]

template<typename T , size_t N>
ConstIterator esphome::StaticRingBuffer< T, N >::begin ( ) const
inline

Definition at line 361 of file helpers.h.

◆ empty()

template<typename T , size_t N>
bool esphome::StaticRingBuffer< T, N >::empty ( ) const
inline

Definition at line 357 of file helpers.h.

◆ end() [1/2]

template<typename T , size_t N>
Iterator esphome::StaticRingBuffer< T, N >::end ( )
inline

Definition at line 360 of file helpers.h.

◆ end() [2/2]

template<typename T , size_t N>
ConstIterator esphome::StaticRingBuffer< T, N >::end ( ) const
inline

Definition at line 362 of file helpers.h.

◆ front() [1/2]

template<typename T , size_t N>
T & esphome::StaticRingBuffer< T, N >::front ( )
inline

Definition at line 354 of file helpers.h.

◆ front() [2/2]

template<typename T , size_t N>
const T & esphome::StaticRingBuffer< T, N >::front ( ) const
inline

Definition at line 355 of file helpers.h.

◆ pop()

template<typename T , size_t N>
void esphome::StaticRingBuffer< T, N >::pop ( )
inline

Definition at line 347 of file helpers.h.

◆ push()

template<typename T , size_t N>
bool esphome::StaticRingBuffer< T, N >::push ( const T & value)
inline

Definition at line 337 of file helpers.h.

◆ size()

template<typename T , size_t N>
index_type esphome::StaticRingBuffer< T, N >::size ( ) const
inline

Definition at line 356 of file helpers.h.

Field Documentation

◆ count_

template<typename T , size_t N>
index_type esphome::StaticRingBuffer< T, N >::count_ {0}
protected

Definition at line 368 of file helpers.h.

◆ data_

template<typename T , size_t N>
T esphome::StaticRingBuffer< T, N >::data_[N]
protected

Definition at line 365 of file helpers.h.

◆ head_

template<typename T , size_t N>
index_type esphome::StaticRingBuffer< T, N >::head_ {0}
protected

Definition at line 366 of file helpers.h.

◆ tail_

template<typename T , size_t N>
index_type esphome::StaticRingBuffer< T, N >::tail_ {0}
protected

Definition at line 367 of file helpers.h.


The documentation for this class was generated from the following file: