CTRE Phoenix 6 C++ 25.0.0-beta-4
Loading...
Searching...
No Matches
ctre::phoenix6::swerve::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 <ctre/phoenix6/swerve/utility/circular_buffer.hpp>

Classes

class  const_iterator
 
class  iterator
 

Public Member Functions

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

Detailed Description

template<class T>
class ctre::phoenix6::swerve::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 >
ctre::phoenix6::swerve::circular_buffer< T >::circular_buffer ( size_t size)
inlineexplicit

Constructs a circular buffer.

Parameters
sizeMaximum number of buffer elements.

◆ circular_buffer() [2/3]

template<class T >
ctre::phoenix6::swerve::circular_buffer< T >::circular_buffer ( const circular_buffer< T > & )
default

◆ circular_buffer() [3/3]

template<class T >
ctre::phoenix6::swerve::circular_buffer< T >::circular_buffer ( circular_buffer< T > && )
default

Member Function Documentation

◆ back() [1/2]

template<class T >
T & ctre::phoenix6::swerve::circular_buffer< T >::back ( )
inline

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 & ctre::phoenix6::swerve::circular_buffer< T >::back ( ) const
inline

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 ctre::phoenix6::swerve::circular_buffer< T >::begin ( )
inline

◆ begin() [2/2]

template<class T >
const_iterator ctre::phoenix6::swerve::circular_buffer< T >::begin ( ) const
inline

◆ cbegin()

template<class T >
const_iterator ctre::phoenix6::swerve::circular_buffer< T >::cbegin ( ) const
inline

◆ cend()

template<class T >
const_iterator ctre::phoenix6::swerve::circular_buffer< T >::cend ( ) const
inline

◆ emplace_back()

template<class T >
template<class... Args>
void ctre::phoenix6::swerve::circular_buffer< T >::emplace_back ( Args &&... args)
inline

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 ctre::phoenix6::swerve::circular_buffer< T >::emplace_front ( Args &&... args)
inline

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 ctre::phoenix6::swerve::circular_buffer< T >::end ( )
inline

◆ end() [2/2]

template<class T >
const_iterator ctre::phoenix6::swerve::circular_buffer< T >::end ( ) const
inline

◆ front() [1/2]

template<class T >
T & ctre::phoenix6::swerve::circular_buffer< T >::front ( )
inline

Returns value at front of buffer.

◆ front() [2/2]

template<class T >
const T & ctre::phoenix6::swerve::circular_buffer< T >::front ( ) const
inline

Returns value at front of buffer.

◆ operator=() [1/2]

template<class T >
circular_buffer & ctre::phoenix6::swerve::circular_buffer< T >::operator= ( circular_buffer< T > && )
default

◆ operator=() [2/2]

template<class T >
circular_buffer & ctre::phoenix6::swerve::circular_buffer< T >::operator= ( const circular_buffer< T > & )
default

◆ operator[]() [1/2]

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

◆ operator[]() [2/2]

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

◆ pop_back()

template<class T >
T ctre::phoenix6::swerve::circular_buffer< T >::pop_back ( )
inline

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 ctre::phoenix6::swerve::circular_buffer< T >::pop_front ( )
inline

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 ctre::phoenix6::swerve::circular_buffer< T >::push_back ( T value)
inline

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 ctre::phoenix6::swerve::circular_buffer< T >::push_front ( T value)
inline

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 ctre::phoenix6::swerve::circular_buffer< T >::reset ( )
inline

Empties internal buffer.

◆ resize()

template<class T >
void ctre::phoenix6::swerve::circular_buffer< T >::resize ( size_t size)
inline

Resizes internal buffer to given size.

◆ size()

template<class T >
size_t ctre::phoenix6::swerve::circular_buffer< T >::size ( ) const
inline

Returns number of elements in buffer.


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