Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
CircularBuffer< T > Class Template Reference

#include <circular_buffer.hpp>

Collaboration diagram for CircularBuffer< T >:
Collaboration graph

Public Member Functions

 CircularBuffer (size_t capacity=0)
 
void set_capacity (size_t capacity)
 
void clear ()
 
size_t size () const
 
size_t capacity () const
 
bool empty () const
 
bool full () const
 
void push (const T &item)
 Add item into circular buffer.
 
const T & latest () const
 Access the most recent item.
 
const T & from_end (size_t i) const
 Access i-th element from the end (0 = latest, 1 = previous, ...)
 
const T & operator[] (size_t index) const
 Iterate raw access.
 

Private Attributes

size_t capacity_
 
size_t head_
 
size_t size_
 
std::vector< T > buffer_
 

Detailed Description

template<typename T>
class CircularBuffer< T >

Definition at line 8 of file circular_buffer.hpp.

Constructor & Destructor Documentation

◆ CircularBuffer()

template<typename T >
CircularBuffer< T >::CircularBuffer ( size_t  capacity = 0)
inlineexplicit

Definition at line 10 of file circular_buffer.hpp.

Member Function Documentation

◆ capacity()

template<typename T >
size_t CircularBuffer< T >::capacity ( ) const
inline

Definition at line 25 of file circular_buffer.hpp.

Here is the caller graph for this function:

◆ clear()

template<typename T >
void CircularBuffer< T >::clear ( )
inline

Definition at line 19 of file circular_buffer.hpp.

Here is the caller graph for this function:

◆ empty()

template<typename T >
bool CircularBuffer< T >::empty ( ) const
inline

Definition at line 26 of file circular_buffer.hpp.

◆ from_end()

template<typename T >
const T & CircularBuffer< T >::from_end ( size_t  i) const
inline

Access i-th element from the end (0 = latest, 1 = previous, ...)

Definition at line 48 of file circular_buffer.hpp.

◆ full()

template<typename T >
bool CircularBuffer< T >::full ( ) const
inline

Definition at line 27 of file circular_buffer.hpp.

◆ latest()

template<typename T >
const T & CircularBuffer< T >::latest ( ) const
inline

Access the most recent item.

Definition at line 40 of file circular_buffer.hpp.

◆ operator[]()

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

Iterate raw access.

Definition at line 56 of file circular_buffer.hpp.

◆ push()

template<typename T >
void CircularBuffer< T >::push ( const T &  item)
inline

Add item into circular buffer.

Definition at line 30 of file circular_buffer.hpp.

◆ set_capacity()

template<typename T >
void CircularBuffer< T >::set_capacity ( size_t  capacity)
inline

Definition at line 13 of file circular_buffer.hpp.

Here is the call graph for this function:

◆ size()

template<typename T >
size_t CircularBuffer< T >::size ( ) const
inline

Definition at line 24 of file circular_buffer.hpp.

Here is the caller graph for this function:

Member Data Documentation

◆ buffer_

template<typename T >
std::vector<T> CircularBuffer< T >::buffer_
private

Definition at line 67 of file circular_buffer.hpp.

◆ capacity_

template<typename T >
size_t CircularBuffer< T >::capacity_
private

Definition at line 64 of file circular_buffer.hpp.

◆ head_

template<typename T >
size_t CircularBuffer< T >::head_
private

Definition at line 65 of file circular_buffer.hpp.

◆ size_

template<typename T >
size_t CircularBuffer< T >::size_
private

Definition at line 66 of file circular_buffer.hpp.


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