RingBuffer< ARRAYTYPE, RINGSIZE > Class Template Reference

#include <ringbuffer.h>

Inheritance diagram for RingBuffer< ARRAYTYPE, RINGSIZE >:

详细描述

template<typename ARRAYTYPE, Int RINGSIZE>
class maxon::RingBuffer< ARRAYTYPE, RINGSIZE >

Ring buffer array template. This class implements a ring buffer using your preferred ARRAY type.

Template Parameters
ARRAYTYPE Type of the array.
RINGSIZE Maximum number of elements in the ring buffer.

Classes

class   IteratorTemplate

Public Types

using  T = typename ARRAYTYPE::ValueType
using  Iterator = IteratorTemplate < false >
using  ConstIterator = IteratorTemplate < true >

公共成员函数

ResultRef < T Append (const T &t)
ResultRef < T Append ( T &&t)
MAXON_ATTRIBUTE_FORCE_INLINE ResultPtr < T Append (const std::initializer_list< T > &values)
const MAXON_ATTRIBUTE_FORCE_INLINE T operator[] ( Int idx) const
MAXON_ATTRIBUTE_FORCE_INLINE T operator[] ( Int idx)
const MAXON_ATTRIBUTE_FORCE_INLINE T GetFirst () const
MAXON_ATTRIBUTE_FORCE_INLINE T GetFirst ()
const MAXON_ATTRIBUTE_FORCE_INLINE T GetLast () const
MAXON_ATTRIBUTE_FORCE_INLINE T GetLast ()
void  重置 ()
void  Flush ()
ConstIterator   Begin () const
Iterator   Begin ()
ConstIterator   End () const
Iterator   End ()

Private Attributes

Int   _ringPos

Member Typedef Documentation

◆  T

using T = typename ARRAYTYPE::ValueType

◆  Iterator

using Iterator = IteratorTemplate <false>

◆  ConstIterator

using ConstIterator = IteratorTemplate <true>

成员函数文档编制

◆  Append() [1/3]

ResultRef < T > Append ( const T t )

Adds a new element at the end of the buffer and initializes it with a copy of x.

参数
[in] t Value to be copied.
返回
Element reference or OutOfMemoryError if the initial allocation failed.

◆  Append() [2/3]

ResultRef < T > Append ( T &&  t )

Adds a new element at the end of the buffer and moves the content of x to it.

参数
[in] t Value to be moved.
返回
Element reference or OutOfMemoryError if the initial allocation failed.

◆  Append() [3/3]

MAXON_ATTRIBUTE_FORCE_INLINE ResultPtr < T > Append ( const std::initializer_list< T > &  values )

Appends new elements at the end of the array.

参数
[in] values Initializer list with values to be copied.
返回
Element pointer or OutOfMemoryError if the allocation failed.

◆  operator[]() [1/2]

const MAXON_ATTRIBUTE_FORCE_INLINE T & operator[] ( Int   idx ) const

Array (subscript) operator for non-const objects. Index 0 is the oldest entry.

参数
[in] idx Element index (if it's out of bounds you will get an error in debug code only, otherwise it will crash).
返回
Array element.

◆  operator[]() [2/2]

MAXON_ATTRIBUTE_FORCE_INLINE T & operator[] ( Int   idx )

Array (subscript) operator for non-const objects. Index 0 is the oldest entry.

参数
[in] idx Element index (if it's out of bounds you will get an error in debug code only, otherwise it will crash).
返回
Array element.

◆  GetFirst() [1/2]

const MAXON_ATTRIBUTE_FORCE_INLINE T * GetFirst ( ) const

Returns a pointer to the first element in the ring buffer (which is different from the first element in the array).

返回
Pointer to the first element (nullptr if the buffer is empty).

◆  GetFirst() [2/2]

MAXON_ATTRIBUTE_FORCE_INLINE T * GetFirst ( )

Returns a pointer to the first element in the ring buffer (which is different from the first element in the array).

返回
Pointer to the first element (nullptr if the buffer is empty).

◆  GetLast() [1/2]

const MAXON_ATTRIBUTE_FORCE_INLINE T * GetLast ( ) const

Returns a pointer to the last element in the ring buffer (which is different from the last element in the array).

返回
Pointer to the last element (nullptr if the buffer is empty).

◆  GetLast() [2/2]

MAXON_ATTRIBUTE_FORCE_INLINE T * GetLast ( )

Returns a pointer to the last element in the ring buffer (which is different from the last element in the array).

返回
Pointer to the last element (nullptr if the buffer is empty).

◆  Reset()

void Reset ( )

Deletes all elements (calls destructors and frees memory).

◆  Flush()

void Flush ( )

Deletes all elements, but doesn't free memory (calls destructors though).

◆  Begin() [1/2]

ConstIterator Begin ( ) const

Gets an iterator for the first element. When you modify the array Begin() will change, it is not a constant value.

返回
Iterator for the first element (equal to End() if the array is empty).

◆  Begin() [2/2]

Iterator Begin ( )

Gets an iterator for the first element. When you modify the array Begin() will change, it is not a constant value.

返回
Iterator for the first element (equal to End() if the array is empty).

◆  End() [1/2]

ConstIterator End ( ) const

Gets an iterator for the end ( End() - 1 is the last element if the array is not empty). When you modify the array End() will change, it is not a constant value.

返回
Iterator for the array end (this is behind the last element).

◆  End() [2/2]

Iterator End ( )

Gets an iterator for the end ( End() - 1 is the last element if the array is not empty). When you modify the array End() will change, it is not a constant value.

返回
Iterator for the array end (this is behind the last element).

Member Data Documentation

◆  _ringPos

Int _ringPos
private