CatapultServer
v0.5.0.1 (Elephant)
|
A fixed size circular buffer. More...
Public Member Functions | |
CircularBuffer (size_t size) | |
Creates a circular buffer with the specified size. More... | |
void | push_back (const T &element) |
Appends element to the end of the buffer, possibly overwriting existing elements. More... | |
void | push_back (T &&element) |
Appends element to the end of the buffer, possibly overwriting existing elements. More... | |
constexpr size_t | size () const |
Gets the size of the buffer. More... | |
constexpr size_t | capacity () const |
Gets the capacity of the buffer. More... | |
T & | operator[] (size_t index) |
Gets the element at index. More... | |
const T & | operator[] (size_t index) const |
Gets the element at index. More... | |
Private Member Functions | |
size_t | incrementNext () |
constexpr size_t | truncateIndex (size_t index) const |
Private Attributes | |
const size_t | m_capacity |
std::vector< T > | m_buffer |
size_t | m_next |
A fixed size circular buffer.
|
inlineexplicit |
Creates a circular buffer with the specified size.
|
inlineconstexpr |
Gets the capacity of the buffer.
|
inlineprivate |
|
inline |
Gets the element at index.
|
inline |
Gets the element at index.
|
inline |
Appends element to the end of the buffer, possibly overwriting existing elements.
|
inline |
Appends element to the end of the buffer, possibly overwriting existing elements.
|
inlineconstexpr |
Gets the size of the buffer.
|
inlineconstexprprivate |
|
private |
|
private |
|
private |