ScummVM API documentation
TwinE::RingBuffer< TYPE, SIZE > Class Template Reference

Non allocating buffer class holds a maximum of given entries and allows an endless insert by overrinding previous elements in the buffer. More...

#include <ringbuffer.h>

Classes

class  iterator
 

Public Types

using value_type = TYPE
 

Public Member Functions

iterator begin ()
 
iterator end ()
 
iterator begin () const
 
iterator end () const
 
size_t size () const
 
constexpr size_t capacity () const
 
bool empty () const
 
const TYPE & front () const
 Access to the first element in the buffer. More...
 
TYPE & front ()
 Access to the first element in the buffer. More...
 
const TYPE & back () const
 Access to the last element in the buffer. More...
 
TYPE & back ()
 Access to the last element in the buffer. More...
 
void clear ()
 Clears the whole ring buffer. More...
 
void push_back (const TYPE &x)
 Pushes an element to the end of the buffer.
 
template<typename... _Args>
void emplace_back (_Args &&...args)
 Pushes an elements to the end of the buffer. More...
 
void pop ()
 Removes element from the beginning of the buffer.
 
void erase_back (const size_t n)
 Erase the given amount of elements from the end of the buffer.
 
void erase_front (const size_t n)
 Erase the given amount of elements from the beginning of the buffer.
 
TYPE & operator[] (size_t i)
 
const TYPE & operator[] (size_t i) const
 

Protected Attributes

size_t _size
 
size_t _front
 
size_t _back
 
TYPE _buffer [SIZE]
 

Detailed Description

template<typename TYPE, size_t SIZE = 64u>
class TwinE::RingBuffer< TYPE, SIZE >

Non allocating buffer class holds a maximum of given entries and allows an endless insert by overrinding previous elements in the buffer.

Member Function Documentation

◆ front() [1/2]

template<typename TYPE, size_t SIZE = 64u>
const TYPE& TwinE::RingBuffer< TYPE, SIZE >::front ( ) const
inline

Access to the first element in the buffer.

Note
This is not the same as accessing the index 0 element

◆ front() [2/2]

template<typename TYPE, size_t SIZE = 64u>
TYPE& TwinE::RingBuffer< TYPE, SIZE >::front ( )
inline

Access to the first element in the buffer.

Note
This is not the same as accessing the index 0 element

◆ back() [1/2]

template<typename TYPE, size_t SIZE = 64u>
const TYPE& TwinE::RingBuffer< TYPE, SIZE >::back ( ) const
inline

Access to the last element in the buffer.

Note
This is not the same as accessing the index size-1 element

◆ back() [2/2]

template<typename TYPE, size_t SIZE = 64u>
TYPE& TwinE::RingBuffer< TYPE, SIZE >::back ( )
inline

Access to the last element in the buffer.

Note
This is not the same as accessing the index size-1 element

◆ clear()

template<typename TYPE, size_t SIZE = 64u>
void TwinE::RingBuffer< TYPE, SIZE >::clear ( )
inline

Clears the whole ring buffer.

Note
Does not call any destructors - they are called when the buffer itself gets destroyed

◆ emplace_back()

template<typename TYPE, size_t SIZE = 64u>
template<typename... _Args>
void TwinE::RingBuffer< TYPE, SIZE >::emplace_back ( _Args &&...  args)
inline

Pushes an elements to the end of the buffer.

Note
Performs a move operation

The documentation for this class was generated from the following file: