Dataflow Runtime API  3.1.1.0
Public Member Functions | List of all members
imt::base::core::util::Dequeue< T > Class Template Reference

Dequeue, Queue able to pop/push elements either from front or back. More...

#include <Imt.Base.Core.Util/Dequeue.h>

Public Member Functions

 Dequeue (T *mem, uint16_t queueSize)
 Constructor. More...
 
 ~Dequeue ()
 Destructor. More...
 
void push_back (const T &e)
 Adds a new element to the back of the queue. More...
 
void push_front (const T &e)
 Adds a new element to the front of the queue. More...
 
void pop_front ()
 Removes the front element of the queue. More...
 
void pop_back ()
 Removes the last element of the queue. More...
 
T & front ()
 Returns the front element of the queue. More...
 
const T & front () const
 Returns the front element of the queue. More...
 
T & back ()
 Returns the back element of the queue. More...
 
const T & back () const
 Returns the back element of the queue. More...
 
size_t size () const
 Returns the current number of elements in the queue. More...
 
bool empty () const
 Returns if the queue is empty. More...
 
bool full () const
 Returns if the queue is full. More...
 

Detailed Description

template<typename T>
class imt::base::core::util::Dequeue< T >

Dequeue, Queue able to pop/push elements either from front or back.

Parameters
TThe type of the elements in the queue. The type T must define the = operator! E.g., If a uint8_t array should be used, then put this array into a struct, to implicitly define the = operator.
Note
Check that the used compile does not reorder the operations in the memory. Otherwise this will fail.

Constructor & Destructor Documentation

◆ Dequeue()

template<typename T >
imt::base::core::util::Dequeue< T >::Dequeue ( T *  mem,
uint16_t  queueSize 
)

Constructor.

Parameters
memThe memory to use for the queue.
queueSizeSize of memory assigned to queue.
Note
The queue can only contain up to size-1 elements (full will return true when size returns size-1). This is due to fact, that is not possible to decide if the queue is empty or full in case of head == tail.

◆ ~Dequeue()

template<typename T >
imt::base::core::util::Dequeue< T >::~Dequeue ( )
inline

Destructor.

Member Function Documentation

◆ back() [1/2]

template<typename T >
T& imt::base::core::util::Dequeue< T >::back ( )
inline

Returns the back element of the queue.

Parameters
Referenceto the back element of the queue.
Note
Calling this function on an empty container causes undefined behavior. There is no check if the value is valid. To check this use empty.

◆ back() [2/2]

template<typename T >
const T& imt::base::core::util::Dequeue< T >::back ( ) const
inline

Returns the back element of the queue.

Parameters
Referenceto the back element of the queue.
Note
Calling this function on an empty container causes undefined behavior. There is no check if the value is valid. To check this use empty.

◆ empty()

template<typename T >
bool imt::base::core::util::Dequeue< T >::empty ( ) const
inline

Returns if the queue is empty.

Returns
True if the queue is empty and false otherwise.

◆ front() [1/2]

template<typename T >
T& imt::base::core::util::Dequeue< T >::front ( )
inline

Returns the front element of the queue.

Returns
Reference to the front element of the queue.
Note
Calling this function on an empty container causes undefined behavior. There is no check if the value is valid. To check this use empty.

◆ front() [2/2]

template<typename T >
const T& imt::base::core::util::Dequeue< T >::front ( ) const
inline

Returns the front element of the queue.

Returns
Reference to the front element of the queue.
Note
Calling this function on an empty container causes undefined behavior. There is no check if the value is valid. To check this use empty.

◆ full()

template<typename T >
bool imt::base::core::util::Dequeue< T >::full ( ) const
inline

Returns if the queue is full.

Returns
True if the queue is full and false otherwise.

◆ pop_back()

template<typename T >
void imt::base::core::util::Dequeue< T >::pop_back

Removes the last element of the queue.

In case of an empty queue nothing happens (element is not removed).

◆ pop_front()

template<typename T >
void imt::base::core::util::Dequeue< T >::pop_front

Removes the front element of the queue.

In case of an empty queue nothing happens (element is not removed).

◆ push_back()

template<typename T >
void imt::base::core::util::Dequeue< T >::push_back ( const T &  e)

Adds a new element to the back of the queue.

In case of a full queue nothing happens (element is not added).

Parameters
eThe new element to copy to the queue.

◆ push_front()

template<typename T >
void imt::base::core::util::Dequeue< T >::push_front ( const T &  e)

Adds a new element to the front of the queue.

In case of a full queue nothing happens (element is not added).

Parameters
eThe new element to copy to the queue.

◆ size()

template<typename T >
size_t imt::base::core::util::Dequeue< T >::size

Returns the current number of elements in the queue.

Returns
Number of elements in the queue.

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