WPILibC++ 2023.4.3
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

 circular_buffer (size_t size)
 
 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. More...
 
T & front ()
 Returns value at front of buffer. More...
 
const T & front () const
 Returns value at front of buffer. More...
 
T & back ()
 Returns value at back of buffer. More...
 
const T & back () const
 Returns value at back of buffer. More...
 
void push_front (T value)
 Push a new value onto the front of the buffer. More...
 
void push_back (T value)
 Push a new value onto the back of the buffer. More...
 
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. More...
 
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. More...
 
pop_front ()
 Pop value at front of buffer. More...
 
pop_back ()
 Pop value at back of buffer. More...
 
void resize (size_t size)
 Resizes internal buffer to given size. More...
 
void reset ()
 Empties internal buffer. More...
 
T & operator[] (size_t index)
 
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.

Constructor & Destructor Documentation

◆ circular_buffer() [1/3]

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

◆ circular_buffer() [2/3]

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

◆ circular_buffer() [3/3]

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

Member Function Documentation

◆ back() [1/2]

template<class T >
T & wpi::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 & wpi::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 wpi::circular_buffer< T >::begin ( )
inline

◆ begin() [2/2]

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

◆ cbegin()

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

◆ cend()

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

◆ emplace_back()

template<class T >
template<class... Args>
void wpi::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 wpi::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 wpi::circular_buffer< T >::end ( )
inline

◆ end() [2/2]

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

◆ front() [1/2]

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

Returns value at front of buffer.

◆ front() [2/2]

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

Returns value at front of buffer.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ operator[]() [1/2]

template<class T >
T & wpi::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 & wpi::circular_buffer< T >::operator[] ( size_t  index) const
inline
Returns
Element at index starting from front of buffer.

◆ pop_back()

template<class T >
T wpi::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 wpi::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 wpi::circular_buffer< T >::push_back ( 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 wpi::circular_buffer< T >::push_front ( 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 wpi::circular_buffer< T >::reset ( )
inline

Empties internal buffer.

◆ resize()

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

Resizes internal buffer to given size.

◆ size()

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

Returns number of elements in buffer.


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