Dequeue, Queue able to pop/push elements either from front or back.
More...
#include <Imt.Base.Core.Util/inc/Imt.Base.Core.Util/Dequeue.h>
|
| Dequeue (T *mem, uint16_t queueSize) noexcept |
| Constructor.
|
|
void | push_back (T const &e) |
| Adds a new element to the back of the queue.
|
|
void | push_front (T const &e) |
| Adds a new element to the front of the queue.
|
|
void | pop_front () |
| Removes the front element of the queue.
|
|
void | pop_back () |
| Removes the last element of the queue.
|
|
T & | front () |
| Returns the front element of the queue.
|
|
T const & | front () const |
| Returns the front element of the queue.
|
|
T & | back () |
| Returns the back element of the queue.
|
|
T const & | back () const |
| Returns the back element of the queue.
|
|
size_t | size () const |
| Returns the current number of elements in the queue.
|
|
bool | empty () const |
| Returns if the queue is empty.
|
|
bool | full () const |
| Returns if the queue is full.
|
|
template<typename T>
class imt::base::core::util::Dequeue< T >
Dequeue, Queue able to pop/push elements either from front or back.
- Parameters
-
T | The 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.
Definition at line 58 of file Dequeue.h.
◆ Dequeue()
Constructor.
- Parameters
-
mem | The memory to use for the queue. |
queueSize | Size 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.
Definition at line 207 of file Dequeue.h.
◆ back() [1/2]
Returns the back element of the queue.
- Returns
- Reference to 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.
Definition at line 129 of file Dequeue.h.
◆ back() [2/2]
Returns the back element of the queue.
- Returns
- Reference to 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.
Definition at line 140 of file Dequeue.h.
◆ empty()
Returns if the queue is empty.
- Returns
- True if the queue is empty and false otherwise.
Definition at line 156 of file Dequeue.h.
◆ front() [1/2]
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.
Definition at line 107 of file Dequeue.h.
◆ front() [2/2]
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.
Definition at line 118 of file Dequeue.h.
◆ full()
Returns if the queue is full.
- Returns
- True if the queue is full and false otherwise.
Definition at line 170 of file Dequeue.h.
◆ pop_back()
Removes the last element of the queue.
In case of an empty queue nothing happens (element is not removed).
Definition at line 246 of file Dequeue.h.
◆ pop_front()
Removes the front element of the queue.
In case of an empty queue nothing happens (element is not removed).
Definition at line 233 of file Dequeue.h.
◆ push_back()
Adds a new element to the back of the queue.
In case of a full queue nothing happens (element is not added).
- Parameters
-
e | The new element to copy to the queue. |
Definition at line 215 of file Dequeue.h.
◆ push_front()
Adds a new element to the front of the queue.
In case of a full queue nothing happens (element is not added).
- Parameters
-
e | The new element to copy to the queue. |
Definition at line 224 of file Dequeue.h.
◆ size()
Returns the current number of elements in the queue.
- Returns
- Number of elements in the queue.
Definition at line 259 of file Dequeue.h.
The documentation for this class was generated from the following file:
- C:/src/imt/Imt.Base-cpp/Imt.Base/Imt.Base.Core.Util/inc/Imt.Base.Core.Util/Dequeue.h