#include <robometry/CircularBuffer.h>
template<class T>
CircularBuffer class
Fixed-capacity storage, iterated from oldest to newest.
Inserting into a full buffer overwrites its oldest element; inserting at capacity zero does nothing. Raw storage is allocated only on construction or capacity changes. Only live elements are constructed and destroyed; unused capacity is left untouched. Elements themselves may allocate memory.
Copies own their elements independently. Structural modifications invalidate iterators. Access from multiple threads requires external synchronization.
Public types
-
template<bool IsConst>class Iterator
- using value_type = T
- using size_type = std::size_t
- using iterator = Iterator<false>
- using const_iterator = Iterator<true>
Constructors, destructors, conversion operators
- CircularBuffer(size_type capacity = 0) explicit
- ~CircularBuffer()
- CircularBuffer(const CircularBuffer& other)
- CircularBuffer(CircularBuffer&& other) noexcept
Public functions
- auto operator=(const CircularBuffer& other) -> CircularBuffer&
- auto operator=(CircularBuffer&& other) -> CircularBuffer& noexcept
- auto size() const -> size_type noexcept
- auto capacity() const -> size_type noexcept
- auto empty() const -> bool noexcept
- auto full() const -> bool noexcept
- auto operator[](size_type index) -> T& noexcept
- auto operator[](size_type index) const -> const T& noexcept
- auto front() -> T& noexcept
- auto front() const -> const T& noexcept
- auto back() -> T& noexcept
- auto back() const -> const T& noexcept
- void push_back(const T& value)
- void push_back(T&& value)
- void pop_back() noexcept
- void pop_front() noexcept
- void clear() noexcept
- void set_capacity(size_type new_capacity)
- Change capacity, preserving the oldest elements when shrinking.
- void resize(size_type new_size, const T& value = T())
- Remove newest elements or append copies of value; grow capacity if needed.
- auto begin() -> iterator noexcept
- auto end() -> iterator noexcept
-
auto begin() const -> const_
iterator noexcept -
auto end() const -> const_
iterator noexcept -
auto cbegin() const -> const_
iterator noexcept -
auto cend() const -> const_
iterator noexcept - void swap(CircularBuffer& other) noexcept