A circular buffer of fixed size. Appending can be done indefinitely, as the index will just loop back around to the beginning.
More...
|
|
| circularBuffer () noexcept |
| | Default constructor.
|
| template<typename... ARGS> |
| | circularBuffer (const ARGS &...args) noexcept |
| | Initialize the buffer with the contents of an array.
|
| | circularBuffer (TYPE default_value) noexcept |
| | Initialize all elements with a single value.
|
| size_t | size () const noexcept override |
| | Get the size of the object in memory.
|
| int | length () const noexcept override |
| | Get the length of the array.
|
| const TYPE & | at (const int index) const noexcept override |
| | Get an element from the buffer.
|
| TYPE & | at (const int index) noexcept |
| | Get a modifiable element from the buffer.
|
| void | append (const TYPE value) noexcept |
| | Add a value to the buffer, and increment the current index.
|
| int | index () const noexcept |
| | Get the index of the current top of the buffer.
|
| TYPE & | current () noexcept |
| | Get a reference to the topmost item in the buffer.
|
| int | count () const noexcept |
| | Get the total number of items in the buffer.
|
|
void | prev () noexcept |
| | Move current "top" to the previous spot in the buffer.
|
|
void | next () noexcept |
| | Move current "top" to the next spot in the buffer.
|
| circularIterator< TYPE, LEN > | begin () const noexcept override |
| | Get an iterator for the first element in this object.
|
| circularIterator< TYPE, LEN > | end () const noexcept override |
| | Get an iterator after the last element of this object.
|
| template<typename... ARGS> |
| void | populate (const TYPE &first, const ARGS &...args) noexcept |
| | Append an arbitrary number of elements to the buffer.
|
| void | populate (const TYPE &arg) noexcept |
| | Append an element to the buffer.
|
| TYPE | minimum () const noexcept |
| | Get the minimum value contained in this buffer.
|
| TYPE | maximum () const noexcept |
| | Get the maximum value contained in this buffer.
|
| double | average () const noexcept |
| | Get the average (mean) value contained in this buffer.
|
| virtual const TYPE & | operator[] (int index) const |
| | Function to get the object at the given index.
|
template<typename TYPE, unsigned int LEN>
class z::core::circularBuffer< TYPE, LEN >
A circular buffer of fixed size. Appending can be done indefinitely, as the index will just loop back around to the beginning.
template<typename TYPE, unsigned int LEN>
template<typename... ARGS>
Initialize the buffer with the contents of an array.
This allows for brace-enclosed initialization e.g. circularBuffer<int, 3> buffer = {1, 2, 3};
- Parameters
-
| args | A list of elements to append to the buffer. |