Main MRPT website > C++ reference
MRPT logo
Public Member Functions | Private Attributes
mrpt::utils::circular_buffer Class Reference

Detailed Description

A circular buffer of fixed size (defined at construction-time), implemented with a std::vector as the underlying storage.

#include <mrpt/utils/circular_buffer.h>

Inheritance diagram for mrpt::utils::circular_buffer:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 circular_buffer (const size_t size)
void push (T d)
 Insert a copy of the given element in the buffer.
void push_ref (const T &d)
 Insert a reference of the given element in the buffer.
void push_many (T *array_elements, size_t count)
 Insert an array of elements in the buffer.
pop ()
 Retrieve an element from the buffer.
void pop (T &out_val)
 Retrieve an element from the buffer.
void pop_many (T *out_array, size_t count)
 Pop a number of elements into a user-provided array.
size_t size () const
 Return the number of elements available for read ("pop") in the buffer (this is NOT the maximum size of the internal buffer)
size_t capacity () const
 Return the maximum capacity of the buffer.
size_t available () const
 The maximum number of elements that can be written ("push") without rising an overflow error.
void clear ()
 Delete all the stored data, if any.

Private Attributes

std::vector< T > m_data
const size_t m_size
size_t m_next_read
size_t m_next_write

Constructor & Destructor Documentation

mrpt::utils::circular_buffer::circular_buffer ( const size_t  size) [inline]

Definition at line 52 of file circular_buffer.h.


Member Function Documentation

size_t mrpt::utils::circular_buffer::available ( ) const [inline]

The maximum number of elements that can be written ("push") without rising an overflow error.

Definition at line 141 of file circular_buffer.h.

size_t mrpt::utils::circular_buffer::capacity ( ) const [inline]

Return the maximum capacity of the buffer.

See also:
size

Definition at line 135 of file circular_buffer.h.

Referenced by mrpt::utils::circular_buffer< uint8_t >::available().

void mrpt::utils::circular_buffer::clear ( void  ) [inline]

Delete all the stored data, if any.

Definition at line 146 of file circular_buffer.h.

T mrpt::utils::circular_buffer::pop ( ) [inline]

Retrieve an element from the buffer.

Exceptions:
std::out_of_rangeIf the buffer is empty.

Definition at line 95 of file circular_buffer.h.

Referenced by mrpt::utils::circular_buffer< uint8_t >::pop_many().

void mrpt::utils::circular_buffer::pop ( T &  out_val) [inline]

Retrieve an element from the buffer.

Exceptions:
std::out_of_rangeIf the buffer is empty.

Definition at line 107 of file circular_buffer.h.

void mrpt::utils::circular_buffer::pop_many ( T *  out_array,
size_t  count 
) [inline]

Pop a number of elements into a user-provided array.

Exceptions:
std::out_of_rangeIf the buffer has less elements than requested.

Definition at line 118 of file circular_buffer.h.

void mrpt::utils::circular_buffer::push ( d) [inline]

Insert a copy of the given element in the buffer.

Exceptions:
std::out_of_rangeIf the buffer run out of space.

Definition at line 65 of file circular_buffer.h.

Referenced by mrpt::utils::circular_buffer< uint8_t >::push_many().

void mrpt::utils::circular_buffer::push_many ( T *  array_elements,
size_t  count 
) [inline]

Insert an array of elements in the buffer.

Exceptions:
std::out_of_rangeIf the buffer run out of space.

Definition at line 87 of file circular_buffer.h.

void mrpt::utils::circular_buffer::push_ref ( const T &  d) [inline]

Insert a reference of the given element in the buffer.

Exceptions:
std::out_of_rangeIf the buffer run out of space.

Definition at line 76 of file circular_buffer.h.

size_t mrpt::utils::circular_buffer::size ( ) const [inline]

Return the number of elements available for read ("pop") in the buffer (this is NOT the maximum size of the internal buffer)

See also:
capacity

Definition at line 126 of file circular_buffer.h.

Referenced by mrpt::utils::circular_buffer< uint8_t >::available().


Member Data Documentation

const size_t mrpt::utils::circular_buffer::m_size [private]



Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011