CoreComponents 3.0.0
A Modern C++ Toolkit
|
Fixed-size circular data buffer More...
#include <cc/CircularBuffer>
Public Member Functions | |
CircularBuffer (Dim< 1 > dim) | |
Allocate a new circular buffer of capacity dim[0]. | |
int | size () const |
Buffer capacity. | |
int | fill () const |
Current fill level. | |
T | at (int i) const |
Get the i-th item from the front. | |
T | operator[] (int i) const |
Get the i-th item from the front. | |
T | first () const |
Get the first item. | |
T | last () const |
Get the last item. | |
T | front (int i=0) const |
Get the i-th item from the front. | |
T | back (int i=0) const |
Get the i-th item from the end. | |
void | pushBack (const T &item) |
Insert item at the end. | |
void | pushFront (const T &item) |
Insert item at the front. | |
void | popFront () |
Remove an item from the front. | |
void | popBack () |
Remove an item from the end. | |
void | deplete () |
Reset to an empty state. | |
CircularBuffer & | operator<< (const T &item) |
Insert item as a new last item. | |
CircularBuffer & | operator>> (T &item) |
Remove and return the first item. | |
Static Public Member Functions | |
static CircularBuffer | allocate (int size) |
Allocate a new circular buffer of capacity size. | |
Fixed-size circular data buffer
T | Item type |
CircularBuffer | ( | Dim< 1 > | dim | ) |
Allocate a new circular buffer of capacity dim[0].
|
static |
Allocate a new circular buffer of capacity size.
int size | ( | ) | const |
Buffer capacity.
int fill | ( | ) | const |
Current fill level.
T at | ( | int | i | ) | const |
Get the i-th item from the front.
T operator[] | ( | int | i | ) | const |
Get the i-th item from the front.
T first | ( | ) | const |
Get the first item.
T last | ( | ) | const |
Get the last item.
T front | ( | int | i = 0 | ) | const |
Get the i-th item from the front.
T back | ( | int | i = 0 | ) | const |
Get the i-th item from the end.
void pushBack | ( | const T & | item | ) |
Insert item at the end.
void pushFront | ( | const T & | item | ) |
Insert item at the front.
void popFront | ( | ) |
Remove an item from the front.
void popBack | ( | ) |
Remove an item from the end.
void deplete | ( | ) |
Reset to an empty state.
CircularBuffer & operator<< | ( | const T & | item | ) |
Insert item as a new last item.
CircularBuffer & operator>> | ( | T & | item | ) |
Remove and return the first item.