|
transwarp
|
A simple circular buffer (FIFO). ValueType must support default construction. The buffer lets you push new values onto the back and pop old values off the front. More...
#include <transwarp.h>
Public Types | |
| using | value_type = ValueType |
Public Member Functions | |
| circular_buffer (std::size_t capacity) | |
| Constructs a circular buffer with a given fixed capacity. | |
| circular_buffer (const circular_buffer &)=delete | |
| circular_buffer & | operator= (const circular_buffer &)=delete |
| circular_buffer (circular_buffer &&other)=delete | |
| circular_buffer & | operator= (circular_buffer &&)=delete |
| template<typename T , typename = typename std::enable_if<std::is_same<typename std::decay<T>::type, value_type>::value>::type> | |
| void | push (T &&value) |
| Pushes a new value onto the end of the buffer. If that exceeds the capacity of the buffer then the oldest value gets dropped (the one at the front). | |
| const value_type & | front () const |
| Returns the value at the front of the buffer (the oldest value). This is undefined if the buffer is empty. | |
| void | pop () |
| Removes the value at the front of the buffer (the oldest value) | |
| std::size_t | capacity () const |
| Returns the capacity of the buffer. | |
| std::size_t | size () const |
| Returns the number of populated values of the buffer. Its maximum value equals the capacity of the buffer. | |
| bool | empty () const |
| Returns whether the buffer is empty. | |
| bool | full () const |
| Returns whether the buffer is full. | |
| void | swap (circular_buffer &buffer) |
| Swaps this buffer with the given buffer. | |
A simple circular buffer (FIFO). ValueType must support default construction. The buffer lets you push new values onto the back and pop old values off the front.
1.8.17