M5Utility 0.0.2 git rev:5c1a751
Loading...
Searching...
No Matches
m5::container::CircularBuffer< T > Class Template Reference

Type CircularBuffer giving size in constructor. More...

#include <circular_buffer.hpp>

Inheritance diagram for m5::container::CircularBuffer< T >:
m5::container::FixedCircularBuffer< T, N >

Public Types

using value_type = T
 
using size_type = size_t
 
using reference = T&
 
using const_reference = const T&
 
using return_type = m5::stl::optional<value_type>
 
using reverse_iterator = std::reverse_iterator<iterator>
 
using const_reverse_iterator = std::reverse_iterator<const_iterator>
 

Public Member Functions

Constructor
 CircularBuffer (const size_t n)
 
 CircularBuffer (const size_type n, const_reference value)
 
template<class InputIter >
 CircularBuffer (const size_type n, InputIter first, InputIter last)
 
 CircularBuffer (const size_type n, std::initializer_list< T > il)
 
 CircularBuffer (const CircularBuffer &)=default
 
 CircularBuffer (CircularBuffer &&) noexcept=default
 
Assignment
CircularBufferoperator= (const CircularBuffer &)=default
 Copy.
 
CircularBufferoperator= (CircularBuffer &&)=default
 Move.
 
template<class InputIterator >
void assign (InputIterator first, InputIterator last)
 Replaces the contents with copies of those in the range [first, last)
 
void assign (size_type n, const_reference v)
 assigns values to the container
 
void assign (std::initializer_list< T > il)
 assigns values to the container
 
Element access
return_type front () const
 Access the first element.
 
return_type back () const
 Access the last element.
 
const_reference operator[] (size_type i) const &
 Access specified element.
 
return_type at (size_type i) const
 Access specified element with bounds checking.
 
size_t read (value_type *outbuf, const size_t num)
 Read from buffer.
 
Capacity
bool empty () const
 checks whether the container is empty
 
bool full () const
 checks whether the container is full
 
size_type size () const
 returns the number of elements
 
size_type capacity () const
 Returns the number of elements that can be held in currently storage.
 
Modifiers
void clear ()
 Clears the contents.
 
void push_front (const value_type &v)
 Adds an element to the top.
 
void push_back (const value_type &v)
 Adds an element to the end.
 
void pop_front ()
 removes the top element
 
void pop_back ()
 removes the end element
 
Operations
void fill (const value_type &v)
 Assigns the value to all elements in the container.
 
void swap (CircularBuffer &o)
 Swaps the contents.
 
Iterator
Note
Iterator is bidirectional
iterator begin () noexcept
 
iterator end () noexcept
 
const_iterator cbegin () const noexcept
 
const_iterator cend () const noexcept
 
reverse_iterator rbegin () noexcept
 
reverse_iterator rend () noexcept
 
const_reverse_iterator crbegin () const noexcept
 
const_reverse_iterator crend () const noexcept
 

Related Symbols

(Note that these are not member symbols.)

template<typename T >
void swap (m5::container::CircularBuffer< T > &a, m5::container::CircularBuffer< T > &b)
 Specializes the std::swap algorithm.
 

Detailed Description

template<typename T>
class m5::container::CircularBuffer< T >

Type CircularBuffer giving size in constructor.

Template Parameters
TType of the element

Member Function Documentation

◆ assign() [1/3]

template<typename T >
template<class InputIterator >
void m5::container::CircularBuffer< T >::assign ( InputIterator first,
InputIterator last )
inline

Replaces the contents with copies of those in the range [first, last)

Parameters
first,lastThe Range to copy the elements from

◆ assign() [2/3]

template<typename T >
void m5::container::CircularBuffer< T >::assign ( size_type n,
const_reference v )
inline

assigns values to the container

Parameters
nNumber of elements
vValue to assign to the elements
Note
Fill with the value as many times as n or the capacity

◆ assign() [3/3]

template<typename T >
void m5::container::CircularBuffer< T >::assign ( std::initializer_list< T > il)
inline

assigns values to the container

Parameters
ilInitializer list from which the copy is made

◆ at()

template<typename T >
return_type m5::container::CircularBuffer< T >::at ( size_type i) const
inline

Access specified element with bounds checking.

Returns
m5::stl::optional<value_type>

◆ back()

template<typename T >
return_type m5::container::CircularBuffer< T >::back ( ) const
inline

Access the last element.

Returns
m5::stl::optional<value_type>

◆ empty()

template<typename T >
bool m5::container::CircularBuffer< T >::empty ( ) const
inline

checks whether the container is empty

Returns
True if empty

◆ fill()

template<typename T >
void m5::container::CircularBuffer< T >::fill ( const value_type & v)
inline

Assigns the value to all elements in the container.

Parameters
vValue to assign to the elements

◆ front()

template<typename T >
return_type m5::container::CircularBuffer< T >::front ( ) const
inline

Access the first element.

Returns
m5::stl::optional<value_type>

◆ full()

template<typename T >
bool m5::container::CircularBuffer< T >::full ( ) const
inline

checks whether the container is full

Returns
True if full

◆ operator[]()

template<typename T >
const_reference m5::container::CircularBuffer< T >::operator[] ( size_type i) const &
inline

Access specified element.

Returns
Reference to the requested element

◆ read()

template<typename T >
size_t m5::container::CircularBuffer< T >::read ( value_type * outbuf,
const size_t num )
inline

Read from buffer.

Parameters
[out]outbufOutput buffer
numMax elements of output buffer
Returns
Number of elements read

◆ swap()

template<typename T >
void m5::container::CircularBuffer< T >::swap ( CircularBuffer< T > & o)
inline

Swaps the contents.

Parameters
oCcontainer to exchange the contents with

Friends And Related Symbol Documentation

◆ swap()

template<typename T >
void swap ( m5::container::CircularBuffer< T > & a,
m5::container::CircularBuffer< T > & b )
related

Specializes the std::swap algorithm.

Parameters
a,bContainers whose contents to swap