KDStateMachineEditor API Documentation  1.2.50
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(), setCapacity()

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)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDStateMachineEditor
Create Qt State Machine metacode using a graphical user interface
https://github.com/KDAB/KDStateMachineEditor