|
| std::size_t | capacity () const noexcept |
| | Maximum number of elements that can be stored.
|
| |
| | CircularBuffer (CircularBuffer &&)=delete |
| | Move operations are optional.
|
| |
| | CircularBuffer (const CircularBuffer &other) |
| | Copy constructor.
|
| |
| | CircularBuffer (std::size_t capacity) |
| | Construct a buffer with the given capacity.
|
| |
| void | clear () noexcept |
| | Remove all elements, keeping the allocated storage.
|
| |
| bool | empty () const noexcept |
| | True if the buffer is empty.
|
| |
| bool | full () const noexcept |
| | True if the buffer is full.
|
| |
| bool | latest (T &out) const |
| | Get a copy of the newest element without removing it.
|
| |
| const T & | latest_ref () const |
| | Get a const reference to the newest element without removing it.
|
| |
| CircularBuffer & | operator= (CircularBuffer &&)=delete |
| |
| CircularBuffer & | operator= (const CircularBuffer &other) |
| | Copy assignment.
|
| |
| bool | pop (T &out) |
| | Pop the oldest element.
|
| |
| void | push (const T &value) |
| | Push a new element (copy). Overwrites the oldest if the buffer is full.
|
| |
| void | push (T &&value) |
| | Push a new element (move). Overwrites the oldest if the buffer is full.
|
| |
| DebugSlotView | raw_slot (std::size_t idx) const |
| |
| std::size_t | size () const noexcept |
| | Current number of valid elements.
|
| |
template<typename T>
class easynav::CircularBuffer< T >
Fixed-size circular buffer, thread-safe (mutex-based), copyable.
All storage is allocated in the constructor. Push and pop never allocate. Copying the buffer creates a new internal storage and copies the content. This class is safe for multiple producers and consumers, but access is serialized by a single mutex.