KDStateMachineEditor API Documentation 2.1
Loading...
Searching...
No Matches
Public Member Functions | List of all members
KDSME::RingBuffer< T > Class Template Reference

#include <ringbuffer.h>

Public Member Functions

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

Definition at line 38 of file ringbuffer.h.

Constructor & Destructor Documentation

◆ RingBuffer()

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

Construct a ring buffer with initial capacity capacity

Definition at line 44 of file ringbuffer.h.

Member Function Documentation

◆ at()

template<class T >
const T & KDSME::RingBuffer< T >::at ( int  i) const
inline

Definition at line 79 of file ringbuffer.h.

◆ clear()

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

Clear the buffer

Definition at line 74 of file ringbuffer.h.

◆ enqueue()

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

Adds value t to the tail of the queue.

Definition at line 65 of file ringbuffer.h.

◆ entries()

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

Definition at line 103 of file ringbuffer.h.

◆ head()

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.

Definition at line 91 of file ringbuffer.h.

◆ last()

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.

Definition at line 99 of file ringbuffer.h.

◆ setCapacity()

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()

Definition at line 55 of file ringbuffer.h.

◆ size()

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

Definition at line 83 of file ringbuffer.h.


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
Generated on Tue Jul 15 2025 15:21:47 for KDStateMachineEditor API Documentation by doxygen 1.9.8