ESPHome 2026.9.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
 
void clear ()
 Clear all elements (reset to empty)
 
Iterator begin ()
 
Iterator end ()
 
ConstIterator begin () const
 
ConstIterator end () const
 

Protected Attributes

T 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 332 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 395 of file helpers.h.

◆ begin() [2/2]

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

Definition at line 397 of file helpers.h.

◆ clear()

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

Clear all elements (reset to empty)

Definition at line 389 of file helpers.h.

◆ empty()

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

Definition at line 386 of file helpers.h.

◆ end() [1/2]

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

Definition at line 396 of file helpers.h.

◆ end() [2/2]

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

Definition at line 398 of file helpers.h.

◆ front() [1/2]

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

Definition at line 383 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 384 of file helpers.h.

◆ pop()

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

Definition at line 376 of file helpers.h.

◆ push()

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

Definition at line 366 of file helpers.h.

◆ size()

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

Definition at line 385 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 404 of file helpers.h.

◆ data_

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

Definition at line 401 of file helpers.h.

◆ head_

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

Definition at line 402 of file helpers.h.

◆ tail_

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

Definition at line 403 of file helpers.h.


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