Main MRPT website > C++ reference for MRPT 1.5.9
List of all members | Public Types | Public Member Functions | Protected Attributes
xsens::FifoQueue< T, E > Class Template Reference

Detailed Description

template<class T, bool E = true>
class xsens::FifoQueue< T, E >

A FIFO queue with limited length (cyclic).

The class is based on the STL queue class, but has a limited size. If more items are inserted than would fit, the oldest item is overwritten. The class can only handle pointer types.

Definition at line 31 of file xsens_fifoqueue.h.

#include <xSens_MT3/xsens_fifoqueue.h>

Public Types

typedef T value_type
 The type of the value stored in this queue. More...
 
typedef size_t size_type
 The type of a 'size' value. More...
 

Public Member Functions

 FifoQueue (size_type size=16, bool delOnOverwrite=true)
 Create an empty queue with capacity size. More...
 
template<bool E2>
 FifoQueue (const FifoQueue< T, E2 > &q)
 The copy constructor. More...
 
void eraseAndClear (void)
 
 ~FifoQueue ()
 The destructor. More...
 
template<bool E2>
FifoQueue< T, E > & operator= (const FifoQueue< T, E2 > &q)
 The assignment operator. More...
 
void resize (const size_t size)
 Resize the queue, note that this function clears the queue. More...
 
bool empty () const
 Return true if the queue is empty. More...
 
size_type size () const
 Return the maximum number of elements in the queue. More...
 
size_type length () const
 Return the number of elements currnetly in the queue. More...
 
value_typefront ()
 Return the oldest element in the queue. More...
 
const value_typefront () const
 Return the oldest element in the queue. More...
 
value_typeback ()
 Return the newest element in the queue. More...
 
const value_typeback () const
 Return the newest element in the queue. More...
 
void push (const value_type &x)
 Insert x at the back of the queue. More...
 
void pop (void)
 Remove the element at the front of the queue. More...
 
void popBack (void)
 Remove the element at the back of the queue. More...
 
const value_typeoperator[] (size_t index) const
 Return the index'th oldest item from the queue. More...
 
value_typeoperator[] (size_t index)
 Return the index'th oldest item from the queue. More...
 
void clear (void)
 
void remove (size_t index)
 

Protected Attributes

size_t m_maxCount
 
size_t m_currentCount
 
size_t m_first
 
bool m_deleteOnOverwrite
 
T * m_list
 

Member Typedef Documentation

◆ size_type

template<class T, bool E = true>
typedef size_t xsens::FifoQueue< T, E >::size_type

The type of a 'size' value.

Definition at line 62 of file xsens_fifoqueue.h.

◆ value_type

template<class T, bool E = true>
typedef T xsens::FifoQueue< T, E >::value_type

The type of the value stored in this queue.

Definition at line 61 of file xsens_fifoqueue.h.

Constructor & Destructor Documentation

◆ FifoQueue() [1/2]

template<class T, bool E = true>
xsens::FifoQueue< T, E >::FifoQueue ( size_type  size = 16,
bool  delOnOverwrite = true 
)
inline

◆ FifoQueue() [2/2]

template<class T, bool E = true>
template<bool E2>
xsens::FifoQueue< T, E >::FifoQueue ( const FifoQueue< T, E2 > &  q)
inline

◆ ~FifoQueue()

template<class T, bool E = true>
xsens::FifoQueue< T, E >::~FifoQueue ( )
inline

Member Function Documentation

◆ back() [1/2]

template<class T, bool E = true>
value_type& xsens::FifoQueue< T, E >::back ( )
inline

◆ back() [2/2]

template<class T, bool E = true>
const value_type& xsens::FifoQueue< T, E >::back ( ) const
inline

◆ clear()

template<class T, bool E = true>
void xsens::FifoQueue< T, E >::clear ( void  )
inline

◆ empty()

template<class T, bool E = true>
bool xsens::FifoQueue< T, E >::empty ( ) const
inline

Return true if the queue is empty.

Definition at line 148 of file xsens_fifoqueue.h.

References xsens::FifoQueue< T, E >::m_currentCount.

◆ eraseAndClear()

template<class T, bool E = true>
void xsens::FifoQueue< T, E >::eraseAndClear ( void  )
inline

◆ front() [1/2]

template<class T, bool E = true>
value_type& xsens::FifoQueue< T, E >::front ( )
inline

Return the oldest element in the queue.

Definition at line 166 of file xsens_fifoqueue.h.

References xsens::FifoQueue< T, E >::m_first, and xsens::FifoQueue< T, E >::m_list.

◆ front() [2/2]

template<class T, bool E = true>
const value_type& xsens::FifoQueue< T, E >::front ( ) const
inline

Return the oldest element in the queue.

Definition at line 172 of file xsens_fifoqueue.h.

References xsens::FifoQueue< T, E >::m_first, and xsens::FifoQueue< T, E >::m_list.

◆ length()

template<class T, bool E = true>
size_type xsens::FifoQueue< T, E >::length ( ) const
inline

Return the number of elements currnetly in the queue.

Definition at line 160 of file xsens_fifoqueue.h.

References xsens::FifoQueue< T, E >::m_currentCount.

◆ operator=()

template<class T, bool E = true>
template<bool E2>
FifoQueue<T,E>& xsens::FifoQueue< T, E >::operator= ( const FifoQueue< T, E2 > &  q)
inline

◆ operator[]() [1/2]

template<class T, bool E = true>
const value_type& xsens::FifoQueue< T, E >::operator[] ( size_t  index) const
inline

◆ operator[]() [2/2]

template<class T, bool E = true>
value_type& xsens::FifoQueue< T, E >::operator[] ( size_t  index)
inline

◆ pop()

template<class T, bool E = true>
void xsens::FifoQueue< T, E >::pop ( void  )
inline

Remove the element at the front of the queue.

Definition at line 208 of file xsens_fifoqueue.h.

References xsens::FifoQueue< T, E >::m_currentCount, xsens::FifoQueue< T, E >::m_first, xsens::FifoQueue< T, E >::m_maxCount, and QUEUELOG.

Referenced by xsens::FifoQueue< T, E >::remove().

◆ popBack()

template<class T, bool E = true>
void xsens::FifoQueue< T, E >::popBack ( void  )
inline

Remove the element at the back of the queue.

Definition at line 216 of file xsens_fifoqueue.h.

References xsens::FifoQueue< T, E >::m_currentCount, xsens::FifoQueue< T, E >::m_maxCount, and QUEUELOG.

◆ push()

template<class T, bool E = true>
void xsens::FifoQueue< T, E >::push ( const value_type x)
inline

◆ remove()

template<class T, bool E = true>
void xsens::FifoQueue< T, E >::remove ( size_t  index)
inline

◆ resize()

template<class T, bool E = true>
void xsens::FifoQueue< T, E >::resize ( const size_t  size)
inline

◆ size()

template<class T, bool E = true>
size_type xsens::FifoQueue< T, E >::size ( ) const
inline

Return the maximum number of elements in the queue.

Definition at line 154 of file xsens_fifoqueue.h.

References xsens::FifoQueue< T, E >::m_maxCount.

Referenced by xsens::FifoQueue< T, E >::FifoQueue(), and xsens::FifoQueue< T, E >::resize().

Member Data Documentation

◆ m_currentCount

template<class T, bool E = true>
size_t xsens::FifoQueue< T, E >::m_currentCount
protected

◆ m_deleteOnOverwrite

template<class T, bool E = true>
bool xsens::FifoQueue< T, E >::m_deleteOnOverwrite
protected

◆ m_first

template<class T, bool E = true>
size_t xsens::FifoQueue< T, E >::m_first
protected

◆ m_list

template<class T, bool E = true>
T* xsens::FifoQueue< T, E >::m_list
protected

◆ m_maxCount

template<class T, bool E = true>
size_t xsens::FifoQueue< T, E >::m_maxCount
protected



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020