10#ifndef SEMF_UTILS_CORE_BUFFER_LASTINBUFFER_H_
11#define SEMF_UTILS_CORE_BUFFER_LASTINBUFFER_H_
81 this->data()[m_pos++] = data;
82 m_pos %= this->size();
89 for (
size_t i = 0; i < this->size(); i++)
92 this->data()[i] = data;
103 T& data = m_pos >= pos + 1 ? this->data()[m_pos - (pos + 1)] : this->data()[(this->size() + m_pos) - (pos + 1)];
111 m_pos = pos % this->size();
Buffer is a base class for buffer implementations.
T * data() const
Returns the pointer to the first element of the data array.
The LastInBuffer class implements a kind of circular buffer.
void setPos(size_t pos)
Sets the write position of the buffer.
size_t pos() const
Returns the current write position.
virtual void put(T data)
Writes data in the buffer.
virtual ~LastInBuffer()=default
virtual T & operator[](size_t pos) const
Returns the entry from a specific position in the buffer.
void fill(T data)
Fills the whole buffer with the same object content.