WPILibC++ 2025.2.1
Loading...
Searching...
No Matches
wpi::circular_buffer< T > Class Template Reference

This is a simple circular buffer so we don't need to "bucket brigade" copy old values. More...

#include <wpi/circular_buffer.h>

Classes

class  const_iterator
 
class  iterator
 

Public Member Functions

constexpr circular_buffer (size_t size)
 Constructs a circular buffer.
 
constexpr circular_buffer (const circular_buffer &)=default
 
constexpr circular_bufferoperator= (const circular_buffer &)=default
 
constexpr circular_buffer (circular_buffer &&)=default
 
constexpr circular_bufferoperator= (circular_buffer &&)=default
 
constexpr iterator begin ()
 
constexpr iterator end ()
 
constexpr const_iterator begin () const
 
constexpr const_iterator end () const
 
constexpr const_iterator cbegin () const
 
constexpr const_iterator cend () const
 
constexpr size_t size () const
 Returns number of elements in buffer.
 
constexpr T & front ()
 Returns value at front of buffer.
 
constexpr const T & front () const
 Returns value at front of buffer.
 
constexpr T & back ()
 Returns value at back of buffer.
 
constexpr const T & back () const
 Returns value at back of buffer.
 
constexpr void push_front (T value)
 Push a new value onto the front of the buffer.
 
constexpr void push_back (T value)
 Push a new value onto the back of the buffer.
 
template<class... Args>
constexpr void emplace_front (Args &&... args)
 Push a new value onto the front of the buffer that is constructed with the provided constructor arguments.
 
template<class... Args>
constexpr void emplace_back (Args &&... args)
 Push a new value onto the back of the buffer that is constructed with the provided constructor arguments.
 
constexpr T pop_front ()
 Pop value at front of buffer.
 
constexpr T pop_back ()
 Pop value at back of buffer.
 
constexpr void resize (size_t size)
 Resizes internal buffer to given size.
 
constexpr void reset ()
 Empties internal buffer.
 
constexpr T & operator[] (size_t index)
 
constexpr const T & operator[] (size_t index) const
 

Detailed Description

template<class T>
class wpi::circular_buffer< T >

This is a simple circular buffer so we don't need to "bucket brigade" copy old values.

Template Parameters
TBuffer element type.

Constructor & Destructor Documentation

◆ circular_buffer() [1/3]

template<class T >
wpi::circular_buffer< T >::circular_buffer ( size_t size)
inlineexplicitconstexpr

Constructs a circular buffer.

Parameters
sizeMaximum number of buffer elements.

◆ circular_buffer() [2/3]

template<class T >
wpi::circular_buffer< T >::circular_buffer ( const circular_buffer< T > & )
constexprdefault

◆ circular_buffer() [3/3]

template<class T >
wpi::circular_buffer< T >::circular_buffer ( circular_buffer< T > && )
constexprdefault

Member Function Documentation

◆ back() [1/2]

template<class T >
T & wpi::circular_buffer< T >::back ( )
inlineconstexpr

Returns value at back of buffer.

If there are no elements in the buffer, calling this function results in undefined behavior.

◆ back() [2/2]

template<class T >
const T & wpi::circular_buffer< T >::back ( ) const
inlineconstexpr

Returns value at back of buffer.

If there are no elements in the buffer, calling this function results in undefined behavior.

◆ begin() [1/2]

template<class T >
iterator wpi::circular_buffer< T >::begin ( )
inlineconstexpr

◆ begin() [2/2]

template<class T >
const_iterator wpi::circular_buffer< T >::begin ( ) const
inlineconstexpr

◆ cbegin()

template<class T >
const_iterator wpi::circular_buffer< T >::cbegin ( ) const
inlineconstexpr

◆ cend()

template<class T >
const_iterator wpi::circular_buffer< T >::cend ( ) const
inlineconstexpr

◆ emplace_back()

template<class T >
template<class... Args>
void wpi::circular_buffer< T >::emplace_back ( Args &&... args)
inlineconstexpr

Push a new value onto the back of the buffer that is constructed with the provided constructor arguments.

The value at the front is overwritten if the buffer is full.

◆ emplace_front()

template<class T >
template<class... Args>
void wpi::circular_buffer< T >::emplace_front ( Args &&... args)
inlineconstexpr

Push a new value onto the front of the buffer that is constructed with the provided constructor arguments.

The value at the back is overwritten if the buffer is full.

◆ end() [1/2]

template<class T >
iterator wpi::circular_buffer< T >::end ( )
inlineconstexpr

◆ end() [2/2]

template<class T >
const_iterator wpi::circular_buffer< T >::end ( ) const
inlineconstexpr

◆ front() [1/2]

template<class T >
T & wpi::circular_buffer< T >::front ( )
inlineconstexpr

Returns value at front of buffer.

◆ front() [2/2]

template<class T >
const T & wpi::circular_buffer< T >::front ( ) const
inlineconstexpr

Returns value at front of buffer.

◆ operator=() [1/2]

template<class T >
circular_buffer & wpi::circular_buffer< T >::operator= ( circular_buffer< T > && )
constexprdefault

◆ operator=() [2/2]

template<class T >
circular_buffer & wpi::circular_buffer< T >::operator= ( const circular_buffer< T > & )
constexprdefault

◆ operator[]() [1/2]

template<class T >
T & wpi::circular_buffer< T >::operator[] ( size_t index)
inlineconstexpr
Returns
Element at index starting from front of buffer.

◆ operator[]() [2/2]

template<class T >
const T & wpi::circular_buffer< T >::operator[] ( size_t index) const
inlineconstexpr
Returns
Element at index starting from front of buffer.

◆ pop_back()

template<class T >
T wpi::circular_buffer< T >::pop_back ( )
inlineconstexpr

Pop value at back of buffer.

If there are no elements in the buffer, calling this function results in undefined behavior.

◆ pop_front()

template<class T >
T wpi::circular_buffer< T >::pop_front ( )
inlineconstexpr

Pop value at front of buffer.

If there are no elements in the buffer, calling this function results in undefined behavior.

◆ push_back()

template<class T >
void wpi::circular_buffer< T >::push_back ( T value)
inlineconstexpr

Push a new value onto the back of the buffer.

The value at the front is overwritten if the buffer is full.

◆ push_front()

template<class T >
void wpi::circular_buffer< T >::push_front ( T value)
inlineconstexpr

Push a new value onto the front of the buffer.

The value at the back is overwritten if the buffer is full.

◆ reset()

template<class T >
void wpi::circular_buffer< T >::reset ( )
inlineconstexpr

Empties internal buffer.

◆ resize()

template<class T >
void wpi::circular_buffer< T >::resize ( size_t size)
inlineconstexpr

Resizes internal buffer to given size.

◆ size()

template<class T >
size_t wpi::circular_buffer< T >::size ( ) const
inlineconstexpr

Returns number of elements in buffer.


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