MPD
0.20.18
|
A circular buffer. More...
#include <ThreadInputStream.hxx>
Public Types | |
typedef WritableBuffer< T > | Range |
typedef Range::pointer_type | pointer_type |
typedef Range::size_type | size_type |
Public Member Functions | |
constexpr | CircularBuffer (pointer_type _data, size_type _capacity) |
CircularBuffer (const CircularBuffer &other)=delete | |
void | Clear () |
constexpr size_type | GetCapacity () const |
constexpr bool | IsEmpty () const |
constexpr bool | IsFull () const |
constexpr size_type | GetSize () const |
Returns the number of elements stored in this buffer. More... | |
constexpr size_type | GetSpace () const |
Returns the number of elements that can be added to this buffer. More... | |
Range | Write () |
Prepares writing. More... | |
void | Append (size_type n) |
Expands the tail of the buffer, after data has been written to the buffer returned by Write(). More... | |
Range | Read () |
Return a buffer range which may be read. More... | |
void | Consume (size_type n) |
Marks a chunk as consumed. More... | |
Protected Member Functions | |
constexpr size_type | Next (size_type i) const |
Protected Attributes | |
size_type | head |
The next index to be read. More... | |
size_type | tail |
The next index to be written to. More... | |
const size_type | capacity |
const pointer_type | data |
A circular buffer.
This class does not manage buffer memory. It will not allocate or free any memory, it only manages the contents of an existing buffer given to the constructor.
Everything between head and tail is valid data (may wrap around). If both are equal, then the buffer is empty. Due to this implementation detail, the buffer is empty when #size-1 items are stored; the last buffer cell cannot be used.
Definition at line 32 of file ThreadInputStream.hxx.
typedef Range::pointer_type CircularBuffer< T >::pointer_type |
Definition at line 54 of file CircularBuffer.hxx.
typedef WritableBuffer<T> CircularBuffer< T >::Range |
Definition at line 53 of file CircularBuffer.hxx.
typedef Range::size_type CircularBuffer< T >::size_type |
Definition at line 55 of file CircularBuffer.hxx.
|
inline |
Definition at line 72 of file CircularBuffer.hxx.
|
delete |
|
inline |
Expands the tail of the buffer, after data has been written to the buffer returned by Write().
Definition at line 144 of file CircularBuffer.hxx.
|
inline |
Definition at line 85 of file CircularBuffer.hxx.
|
inline |
Marks a chunk as consumed.
Definition at line 173 of file CircularBuffer.hxx.
|
inline |
Definition at line 89 of file CircularBuffer.hxx.
|
inline |
Returns the number of elements stored in this buffer.
Definition at line 104 of file CircularBuffer.hxx.
|
inline |
Returns the number of elements that can be added to this buffer.
Definition at line 114 of file CircularBuffer.hxx.
|
inline |
Definition at line 93 of file CircularBuffer.hxx.
|
inline |
Definition at line 97 of file CircularBuffer.hxx.
|
inlineprotected |
Definition at line 78 of file CircularBuffer.hxx.
|
inline |
Return a buffer range which may be read.
The buffer pointer is writable, to allow modifications while parsing.
Definition at line 163 of file CircularBuffer.hxx.
|
inline |
Prepares writing.
Returns a buffer range which may be written. When you are finished, call Append().
Definition at line 126 of file CircularBuffer.hxx.
|
protected |
Definition at line 68 of file CircularBuffer.hxx.
|
protected |
Definition at line 69 of file CircularBuffer.hxx.
|
protected |
The next index to be read.
Definition at line 61 of file CircularBuffer.hxx.
|
protected |
The next index to be written to.
Definition at line 66 of file CircularBuffer.hxx.