Fawkes API
Fawkes Development Version
|
Circular buffer with a fixed size. More...
#include <>>
Public Types | |
typedef size_t | size_type |
The size_type of the buffer. More... | |
typedef std::deque< Type >::const_iterator | const_iterator |
The CircularBuffer's iterator is a std::deque iterator. More... | |
typedef const_iterator | iterator |
iterator is also const, we don't want to manipulate any elements More... | |
Public Member Functions | |
CircularBuffer (size_type n) | |
Constructor. More... | |
CircularBuffer (const CircularBuffer< Type > &other) | |
Copy constructor. More... | |
virtual | ~CircularBuffer () |
Destructor. More... | |
virtual void | push_back (const Type &val) |
Insert an element at the end of the buffer and delete the first element if necessary. More... | |
virtual void | pop_front () |
Delete the first element. More... | |
virtual size_type | get_max_size () const |
Get the maximum size of the buffer. More... | |
virtual std::deque< Type > | get_deque () const |
Get the deque used to store the elements. More... | |
virtual const Type & | operator[] (size_type n) const |
Element access. More... | |
virtual const Type & | at (size_type n) const |
Element access. More... | |
virtual const Type & | front () const |
Access the first element in the buffer. More... | |
virtual const Type & | back () const |
Access the last element in the buffer. More... | |
virtual const_iterator | begin () const |
Get iterator to the beginning. More... | |
virtual const_iterator | end () const |
Get iterator to the end. More... | |
virtual size_type | size () const |
Get actual size of the buffer. More... | |
Protected Attributes | |
std::deque< Type > | __deque |
The deque used to store the data. More... | |
size_type | __max_size |
The maximum size of the circular buffer. More... | |
Circular buffer with a fixed size.
This class provides a a circular buffer. A circular buffer is a container with a fixed (maximum) size. It automatically maintains its size by removing elements from the front, if necessary. This implementation does not allow any element manipulation other than push_back() and pop_front(). All returned references to elements are constant.
Definition at line 44 of file circular_buffer.h.
typedef std::deque<Type>::const_iterator fawkes::CircularBuffer< Type >::const_iterator |
The CircularBuffer's iterator is a std::deque iterator.
Definition at line 51 of file circular_buffer.h.
typedef const_iterator fawkes::CircularBuffer< Type >::iterator |
iterator is also const, we don't want to manipulate any elements
Definition at line 53 of file circular_buffer.h.
typedef size_t fawkes::CircularBuffer< Type >::size_type |
The size_type of the buffer.
Definition at line 49 of file circular_buffer.h.
|
inline |
Constructor.
n | the maximum size of the buffer |
Definition at line 57 of file circular_buffer.h.
|
inline |
Copy constructor.
other | CircularBuffer to copy |
Definition at line 65 of file circular_buffer.h.
|
inlinevirtual |
Destructor.
Definition at line 71 of file circular_buffer.h.
|
inlinevirtual |
Element access.
n | position of the element |
Definition at line 121 of file circular_buffer.h.
References fawkes::CircularBuffer< Type >::__deque.
|
inlinevirtual |
Access the last element in the buffer.
Definition at line 137 of file circular_buffer.h.
References fawkes::CircularBuffer< Type >::__deque.
|
inlinevirtual |
Get iterator to the beginning.
Definition at line 145 of file circular_buffer.h.
References fawkes::CircularBuffer< Type >::__deque.
|
inlinevirtual |
Get iterator to the end.
Definition at line 153 of file circular_buffer.h.
References fawkes::CircularBuffer< Type >::__deque.
|
inlinevirtual |
Access the first element in the buffer.
Definition at line 129 of file circular_buffer.h.
References fawkes::CircularBuffer< Type >::__deque.
|
inlinevirtual |
Get the deque used to store the elements.
Definition at line 103 of file circular_buffer.h.
References fawkes::CircularBuffer< Type >::__deque.
|
inlinevirtual |
Get the maximum size of the buffer.
Definition at line 95 of file circular_buffer.h.
References fawkes::CircularBuffer< Type >::__max_size.
|
inlinevirtual |
Element access.
n | position of the element |
Definition at line 112 of file circular_buffer.h.
References fawkes::CircularBuffer< Type >::__deque.
|
inlinevirtual |
Delete the first element.
Definition at line 87 of file circular_buffer.h.
References fawkes::CircularBuffer< Type >::__deque.
|
inlinevirtual |
Insert an element at the end of the buffer and delete the first element if necessary.
val | the value to insert |
Definition at line 78 of file circular_buffer.h.
References fawkes::CircularBuffer< Type >::__deque, and fawkes::CircularBuffer< Type >::__max_size.
|
inlinevirtual |
Get actual size of the buffer.
Definition at line 161 of file circular_buffer.h.
References fawkes::CircularBuffer< Type >::__deque.
|
protected |
The deque used to store the data.
Definition at line 168 of file circular_buffer.h.
Referenced by fawkes::CircularBuffer< Type >::at(), fawkes::CircularBuffer< Type >::back(), fawkes::CircularBuffer< Type >::begin(), fawkes::CircularBuffer< Type >::end(), fawkes::CircularBuffer< Type >::front(), fawkes::CircularBuffer< Type >::get_deque(), fawkes::CircularBuffer< Type >::operator[](), fawkes::CircularBuffer< Type >::pop_front(), fawkes::CircularBuffer< Type >::push_back(), and fawkes::CircularBuffer< Type >::size().
|
protected |
The maximum size of the circular buffer.
Definition at line 170 of file circular_buffer.h.
Referenced by fawkes::CircularBuffer< Type >::get_max_size(), and fawkes::CircularBuffer< Type >::push_back().