0.2.0
Loading...
Searching...
No Matches
NAV::ScrollingBuffer< T, _Padding > Class Template Reference

A buffer which is overwriting itself from the start when full. More...

Classes

class  ConstIterator
 Const iterator. More...
 
class  ConstReverseIterator
 Const reverse iterator. More...
 
class  Iterator
 Iterator. More...
 
class  ReverseIterator
 Reverse Iterator. More...
 

Public Member Functions

T & at (size_t pos)
 Returns a reference to the element at specified location pos, with bounds checking. If pos is not within the range of the container, an exception of type std::out_of_range is thrown.
 
const T & at (size_t pos) const
 Returns a reference to the element at specified location pos, with bounds checking. If pos is not within the range of the container, an exception of type std::out_of_range is thrown.
 
T & back ()
 Returns a reference to the last element in the container. Calling back on an empty container causes undefined behavior.
 
const T & back () const
 Returns a reference to the last element in the container. Calling back on an empty container causes undefined behavior.Reference to the last element.
 
Iterator begin ()
 Returns an iterator to the first element of the vector.
 
ConstIterator begin () const
 Returns an iterator to the first element of the vector.
 
size_t capacity () const
 Returns the number of elements that can be held in currently allocated storage.
 
ConstIterator cbegin () const
 Returns an iterator to the first element of the vector.
 
ConstIterator cend () const
 Returns an iterator to the element following the last element of the vector.
 
void clear ()
 Erases all elements from the container. After this call, size() returns zero.
 
ConstReverseIterator crbegin () const
 Returns a reverse iterator to the first element of the reversed vector.
 
ConstReverseIterator crend () const
 Returns a reverse iterator to the element following the last element of the reversed vector.
 
T * data ()
 Returns a pointer to the raw data array (not in scrolled order)
 
const T * data () const
 Returns a pointer to the raw data array (not in scrolled order)
 
bool empty () const
 Checks if the container has no elements.
 
Iterator end ()
 Returns an iterator to the element following the last element of the vector.
 
ConstIterator end () const
 Returns an iterator to the element following the last element of the vector.
 
T & front ()
 Returns a reference to the first element in the container. Calling front on an empty container is undefined.
 
const T & front () const
 Returns a reference to the first element in the container. Calling front on an empty container is undefined.
 
bool full () const
 Checks if the container is full (never full when infinite buffer)
 
std::string getRawString () const
 Converts the raw buffer to a string.
 
bool isInfiniteBuffer () const
 Returns whether the buffer is infinite and growing.
 
max () const
 Returns the largest value in the buffer.
 
min () const
 Returns the smallest value in the buffer.
 
int offset () const
 Returns the data index of the first element in the buffer.
 
void pop_front ()
 Removes the first element of the container.
 
void push_back (const T &value)
 Appends the given element value to the end of the container.
 
ReverseIterator rbegin ()
 Returns a reverse iterator to the first element of the reversed vector.
 
ConstReverseIterator rbegin () const
 Returns a reverse iterator to the first element of the reversed vector.
 
ReverseIterator rend ()
 Returns a reverse iterator to the element following the last element of the reversed vector.
 
ConstReverseIterator rend () const
 Returns a reverse iterator to the element following the last element of the reversed vector.
 
void reserve (size_t new_cap)
 Increase the capacity of the vector to a value that's greater or equal to new_cap.
 
void resize (size_t targetSize)
 Resizes the buffer to the specified size.
 
 ScrollingBuffer (size_t maxSize=0)
 Reserves space for the buffer but does not fill the buffer with values.
 
 ScrollingBuffer (std::initializer_list< T > init)
 Constructs a new container with the contents of the initializer list init.
 
size_t size () const
 Returns the number of elements in the container.
 

Detailed Description

template<class T, size_t _Padding = 0>
class NAV::ScrollingBuffer< T, _Padding >

A buffer which is overwriting itself from the start when full.

Template Parameters
TType of data stored in the buffer
_PaddingThe padding are empty values at the start of the buffer to prevent overriding the start value in multithreaded applications

Constructor & Destructor Documentation

◆ ScrollingBuffer() [1/2]

template<class T , size_t _Padding = 0>
NAV::ScrollingBuffer< T, _Padding >::ScrollingBuffer ( size_t maxSize = 0)
inlineexplicit

Reserves space for the buffer but does not fill the buffer with values.

Parameters
[in]maxSizeThe maximum size of the scrolling buffer

◆ ScrollingBuffer() [2/2]

template<class T , size_t _Padding = 0>
NAV::ScrollingBuffer< T, _Padding >::ScrollingBuffer ( std::initializer_list< T > init)
inline

Constructs a new container with the contents of the initializer list init.

Parameters
[in]initinitializer list to initialize the elements of the container with

Member Function Documentation

◆ at() [1/2]

template<class T , size_t _Padding = 0>
T & NAV::ScrollingBuffer< T, _Padding >::at ( size_t pos)
inline

Returns a reference to the element at specified location pos, with bounds checking. If pos is not within the range of the container, an exception of type std::out_of_range is thrown.

Parameters
[in]posposition of the element to return
Returns
Reference to the requested element.

◆ at() [2/2]

template<class T , size_t _Padding = 0>
const T & NAV::ScrollingBuffer< T, _Padding >::at ( size_t pos) const
inline

Returns a reference to the element at specified location pos, with bounds checking. If pos is not within the range of the container, an exception of type std::out_of_range is thrown.

Parameters
[in]posposition of the element to return
Returns
Reference to the requested element.

◆ back() [1/2]

template<class T , size_t _Padding = 0>
T & NAV::ScrollingBuffer< T, _Padding >::back ( )
inline

Returns a reference to the last element in the container. Calling back on an empty container causes undefined behavior.

Returns
Reference to the last element.

◆ back() [2/2]

template<class T , size_t _Padding = 0>
const T & NAV::ScrollingBuffer< T, _Padding >::back ( ) const
inline

Returns a reference to the last element in the container. Calling back on an empty container causes undefined behavior.Reference to the last element.

Returns
Reference to the last element.

◆ begin() [1/2]

template<class T , size_t _Padding = 0>
Iterator NAV::ScrollingBuffer< T, _Padding >::begin ( )
inline

Returns an iterator to the first element of the vector.

If the buffer is empty, the returned iterator will be equal to end().

◆ begin() [2/2]

template<class T , size_t _Padding = 0>
ConstIterator NAV::ScrollingBuffer< T, _Padding >::begin ( ) const
inline

Returns an iterator to the first element of the vector.

If the buffer is empty, the returned iterator will be equal to end().

◆ cbegin()

template<class T , size_t _Padding = 0>
ConstIterator NAV::ScrollingBuffer< T, _Padding >::cbegin ( ) const
inline

Returns an iterator to the first element of the vector.

If the buffer is empty, the returned iterator will be equal to end().

◆ cend()

template<class T , size_t _Padding = 0>
ConstIterator NAV::ScrollingBuffer< T, _Padding >::cend ( ) const
inline

Returns an iterator to the element following the last element of the vector.

This element acts as a placeholder; attempting to access it results in undefined behavior.

◆ crbegin()

template<class T , size_t _Padding = 0>
ConstReverseIterator NAV::ScrollingBuffer< T, _Padding >::crbegin ( ) const
inline

Returns a reverse iterator to the first element of the reversed vector.

It corresponds to the last element of the non-reversed vector. If the vector is empty, the returned iterator is equal to rend().

◆ crend()

template<class T , size_t _Padding = 0>
ConstReverseIterator NAV::ScrollingBuffer< T, _Padding >::crend ( ) const
inline

Returns a reverse iterator to the element following the last element of the reversed vector.

It corresponds to the element preceding the first element of the non-reversed vector. This element acts as a placeholder, attempting to access it results in undefined behavior.

◆ end() [1/2]

template<class T , size_t _Padding = 0>
Iterator NAV::ScrollingBuffer< T, _Padding >::end ( )
inline

Returns an iterator to the element following the last element of the vector.

This element acts as a placeholder; attempting to access it results in undefined behavior.

◆ end() [2/2]

template<class T , size_t _Padding = 0>
ConstIterator NAV::ScrollingBuffer< T, _Padding >::end ( ) const
inline

Returns an iterator to the element following the last element of the vector.

This element acts as a placeholder; attempting to access it results in undefined behavior.

◆ front() [1/2]

template<class T , size_t _Padding = 0>
T & NAV::ScrollingBuffer< T, _Padding >::front ( )
inline

Returns a reference to the first element in the container. Calling front on an empty container is undefined.

Returns
reference to the first element

◆ front() [2/2]

template<class T , size_t _Padding = 0>
const T & NAV::ScrollingBuffer< T, _Padding >::front ( ) const
inline

Returns a reference to the first element in the container. Calling front on an empty container is undefined.

Returns
Reference to the first element

◆ push_back()

template<class T , size_t _Padding = 0>
void NAV::ScrollingBuffer< T, _Padding >::push_back ( const T & value)
inline

Appends the given element value to the end of the container.

Parameters
[in]valuethe value of the element to append

◆ rbegin() [1/2]

template<class T , size_t _Padding = 0>
ReverseIterator NAV::ScrollingBuffer< T, _Padding >::rbegin ( )
inline

Returns a reverse iterator to the first element of the reversed vector.

It corresponds to the last element of the non-reversed vector. If the vector is empty, the returned iterator is equal to rend().

◆ rbegin() [2/2]

template<class T , size_t _Padding = 0>
ConstReverseIterator NAV::ScrollingBuffer< T, _Padding >::rbegin ( ) const
inline

Returns a reverse iterator to the first element of the reversed vector.

It corresponds to the last element of the non-reversed vector. If the vector is empty, the returned iterator is equal to rend().

◆ rend() [1/2]

template<class T , size_t _Padding = 0>
ReverseIterator NAV::ScrollingBuffer< T, _Padding >::rend ( )
inline

Returns a reverse iterator to the element following the last element of the reversed vector.

It corresponds to the element preceding the first element of the non-reversed vector. This element acts as a placeholder, attempting to access it results in undefined behavior.

◆ rend() [2/2]

template<class T , size_t _Padding = 0>
ConstReverseIterator NAV::ScrollingBuffer< T, _Padding >::rend ( ) const
inline

Returns a reverse iterator to the element following the last element of the reversed vector.

It corresponds to the element preceding the first element of the non-reversed vector. This element acts as a placeholder, attempting to access it results in undefined behavior.

◆ reserve()

template<class T , size_t _Padding = 0>
void NAV::ScrollingBuffer< T, _Padding >::reserve ( size_t new_cap)
inline

Increase the capacity of the vector to a value that's greater or equal to new_cap.

Parameters
new_capNew capacity of the vector, in number of elements

◆ resize()

template<class T , size_t _Padding = 0>
void NAV::ScrollingBuffer< T, _Padding >::resize ( size_t targetSize)
inline

Resizes the buffer to the specified size.

Parameters
[in]targetSizeThe new buffer size (0 for infinite buffer)

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