KDStateMachineEditor  1.0.0
A framework for creating Qt State Machine metacode using a graphical user interface
Public Member Functions | List of all members
KDSME::RingBuffer< T > Class Template Reference

#include <ringbuffer.h>

Public Member Functions

 RingBuffer (int capacity=10)
 
void setCapacity (int capacity)
 
void enqueue (T t)
 
void clear ()
 
const T & at (int i) const
 
int size () const
 
head () const
 
last () const
 
QList< T > entries () const
 

Detailed Description

template<class T>
class KDSME::RingBuffer< T >

This class is similar to a QQueue but provides circular semantics. For example, appending to an already "full" queue will overwrite the oldest item, i.e. it forms a kind of LRU cache.

Or, in other words, RingBuffer is a QQueue with limited capacity.

The API is essentially simplified version of QVector, which additional methods such as enqueue(),

See also
QVector

Constructor & Destructor Documentation

template<class T >
KDSME::RingBuffer< T >::RingBuffer ( int  capacity = 10)
inline

Construct a ring buffer with initial capacity capacity

Member Function Documentation

template<class T >
void KDSME::RingBuffer< T >::clear ( )
inline

Clear the buffer

template<class T >
void KDSME::RingBuffer< T >::enqueue ( t)
inline

Adds value t to the tail of the queue.

template<class T >
T KDSME::RingBuffer< T >::head ( ) const
inline

Returns a reference to the queue's head item. This function assumes that the queue isn't empty.

template<class T >
T KDSME::RingBuffer< T >::last ( ) const
inline

Returns a reference to the last item in the list. The list must not be empty.

template<class T >
void KDSME::RingBuffer< T >::setCapacity ( int  capacity)
inline

(Re-)set the capacity of this ring buffer to capacity

Note
Will run cleanup() afterwards and remove items if capacity decreased
See also
cleanup()

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

Klarälvdalens Datakonsult AB (KDAB)
Qt-related services and products
http://www.kdab.com/
https://github.com/KDAB/KDStateMachineEditor