MT Core (C++)
Core library for replacing C++ standard in project usage
|
Represents a ring buffer with static memory allocation Can be used as a FIFO or LIFO queue Allows memory reuse by wrapping pointers Cannot be dynamically resized. More...
#include <ring_buffer.hpp>
Public Types | |
using | Elem = T |
Public Member Functions | |
decltype(auto) | ptr_iter () noexcept |
Gets a pointer iterator to values. | |
decltype(auto) | ptr_iter () const noexcept |
Gets a constant pointer iterator to values. | |
decltype(auto) | iter () noexcept |
Gets an iterator that returns copies of values. | |
void | init () |
Initializes a new fixed ring buffer. | |
void | init (std::initializer_list< T > list) |
Initializes a new fixed ring buffer with specific elements. | |
const T & | operator[] (size_t i) const noexcept |
Gets an element at a specific index. | |
T & | operator[] (size_t i) noexcept |
Gets an element at a specific index. | |
size_t | size () const noexcept |
Gets current size of the buffer. | |
const T & | at (size_t i) const noexcept |
Gets an element at a specific index. | |
T & | at (size_t i) noexcept |
Gets an element at a specific index. | |
Result< void, CollectionAddNoAllocationError > | push_back (const T &elem) |
Adds an element to the back of the buffer. | |
Result< void, CollectionAddNoAllocationError > | push_front (const T &elem) |
Adds an element to the front of the buffer. | |
Optional< T > | pop_front () |
Removes an element from the front. | |
Optional< T > | pop_back () |
Removes an element from the back. | |
Represents a ring buffer with static memory allocation Can be used as a FIFO or LIFO queue Allows memory reuse by wrapping pointers Cannot be dynamically resized.
Accessing elements is \(O(1)\) Adding elements is \(O(1)\) Removing elements is \(O(1)\)
T | Type of element stored |
Capacity | Max capacity |
Definition at line 356 of file ring_buffer.hpp.
using mtcore::FixedRingBuffer< T, Capacity >::Elem = T |
Definition at line 364 of file ring_buffer.hpp.
|
inlinenodiscardnoexcept |
Gets an element at a specific index.
i | Index |
Definition at line 423 of file ring_buffer.hpp.
|
inlinenodiscardnoexcept |
Gets an element at a specific index.
i | Index |
Definition at line 437 of file ring_buffer.hpp.
|
inline |
|
inline |
Initializes a new fixed ring buffer with specific elements.
Definition at line 392 of file ring_buffer.hpp.
|
inlinenodiscardnoexcept |
Gets an iterator that returns copies of values.
Definition at line 382 of file ring_buffer.hpp.
|
inlinenodiscardnoexcept |
Gets an element at a specific index.
i | Index |
Definition at line 404 of file ring_buffer.hpp.
|
inlinenodiscardnoexcept |
Gets an element at a specific index.
i | Index |
Definition at line 411 of file ring_buffer.hpp.
|
inlinenodiscard |
Removes an element from the back.
Definition at line 509 of file ring_buffer.hpp.
|
inlinenodiscard |
Removes an element from the front.
Definition at line 491 of file ring_buffer.hpp.
|
inlinenodiscardnoexcept |
Gets a constant pointer iterator to values.
Definition at line 376 of file ring_buffer.hpp.
|
inlinenodiscardnoexcept |
Gets a pointer iterator to values.
Definition at line 370 of file ring_buffer.hpp.
|
inlinenodiscard |
Adds an element to the back of the buffer.
elem | Element to add |
Definition at line 451 of file ring_buffer.hpp.
|
inlinenodiscard |
Adds an element to the front of the buffer.
elem | Element to add |
Definition at line 469 of file ring_buffer.hpp.
|
inlinenodiscardnoexcept |