Tool Libs
UMIT-TIROL Institute of Automation and Control Engineering library collection
 
Loading...
Searching...
No Matches
Queue< T > Class Template Reference

simple Buffer backed queue implementation More...

#include <queue.h>

Inherits Sink< T >, and Source< T >.

Collaboration diagram for Queue< T >:
[legend]

Public Member Functions

 Queue (const Buffer< T > &buf)
 create Queue directly from filled Buffer
 
 Queue (size_t size=30)
 create Queue with constant size
 
void push (T &&val) override
 move element into queue
 
T & front ()
 return reference to first element in queue
 
pop () override
 remove front of queue and return it
 
void drop ()
 shift head of queue without touching underlying memory
 
size_t size ()
 return number of elements in queue
 
bool empty () override
 check if queue is empty
 
bool full () override
 return true if queue is full
 
getAt (size_t idx)
 return element at idx
 
virtual void push (const T &t)
 copy semantics does not check for space. guard by using 'if (!full) { ... }'
 
void trypush (T &&t)
 use this if you don't care if it's going to be successful. data gets discarded if sink is full.
 

Detailed Description

template<typename T>
class Queue< T >

simple Buffer backed queue implementation

Member Function Documentation

◆ push()

template<typename T >
void Queue< T >::push ( T &&  val)
inlineoverridevirtual

move element into queue

consider guarding with if(! full()) ...

Implements Sink< T >.

◆ pop()

template<typename T >
T Queue< T >::pop ( )
inlineoverridevirtual

remove front of queue and return it

does not check that there's something in the queue guard with if (size()) ... or if (! empty()) ...

Implements Source< T >.


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