CatapultServer  v0.5.0.1 (Elephant)
catapult::utils::CircularBuffer< T > Class Template Reference

A fixed size circular buffer. More...

Public Member Functions

 CircularBuffer (size_t size)
 Creates a circular buffer with the specified size. More...
 
void push_back (const T &element)
 Appends element to the end of the buffer, possibly overwriting existing elements. More...
 
void push_back (T &&element)
 Appends element to the end of the buffer, possibly overwriting existing elements. More...
 
constexpr size_t size () const
 Gets the size of the buffer. More...
 
constexpr size_t capacity () const
 Gets the capacity of the buffer. More...
 
T & operator[] (size_t index)
 Gets the element at index. More...
 
const T & operator[] (size_t index) const
 Gets the element at index. More...
 

Private Member Functions

size_t incrementNext ()
 
constexpr size_t truncateIndex (size_t index) const
 

Private Attributes

const size_t m_capacity
 
std::vector< T > m_buffer
 
size_t m_next
 

Detailed Description

template<typename T>
class catapult::utils::CircularBuffer< T >

A fixed size circular buffer.

Constructor & Destructor Documentation

◆ CircularBuffer()

template<typename T>
catapult::utils::CircularBuffer< T >::CircularBuffer ( size_t  size)
inlineexplicit

Creates a circular buffer with the specified size.

Member Function Documentation

◆ capacity()

template<typename T>
constexpr size_t catapult::utils::CircularBuffer< T >::capacity ( ) const
inlineconstexpr

Gets the capacity of the buffer.

◆ incrementNext()

template<typename T>
size_t catapult::utils::CircularBuffer< T >::incrementNext ( )
inlineprivate
Here is the caller graph for this function:

◆ operator[]() [1/2]

template<typename T>
T& catapult::utils::CircularBuffer< T >::operator[] ( size_t  index)
inline

Gets the element at index.

◆ operator[]() [2/2]

template<typename T>
const T& catapult::utils::CircularBuffer< T >::operator[] ( size_t  index) const
inline

Gets the element at index.

◆ push_back() [1/2]

template<typename T>
void catapult::utils::CircularBuffer< T >::push_back ( const T &  element)
inline

Appends element to the end of the buffer, possibly overwriting existing elements.

◆ push_back() [2/2]

template<typename T>
void catapult::utils::CircularBuffer< T >::push_back ( T &&  element)
inline

Appends element to the end of the buffer, possibly overwriting existing elements.

◆ size()

template<typename T>
constexpr size_t catapult::utils::CircularBuffer< T >::size ( ) const
inlineconstexpr

Gets the size of the buffer.

◆ truncateIndex()

template<typename T>
constexpr size_t catapult::utils::CircularBuffer< T >::truncateIndex ( size_t  index) const
inlineconstexprprivate
Here is the caller graph for this function:

Member Data Documentation

◆ m_buffer

template<typename T>
std::vector<T> catapult::utils::CircularBuffer< T >::m_buffer
private

◆ m_capacity

template<typename T>
const size_t catapult::utils::CircularBuffer< T >::m_capacity
private

◆ m_next

template<typename T>
size_t catapult::utils::CircularBuffer< T >::m_next
private

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