A C++ template library for embedded applications
Designed and maintained by
Aster Consulting Ltd

queue

A fixed capacity queue.
STL equivalent: std::queue

etl::queue<typename T,
           const size_t SIZE,
           const size_t MEMORY_MODEL = etl::memory_model::MEMORY_MODEL_LARGE>

Inherits from etl::iqueue<T>
etl::iqueue may be used as a size independent pointer or reference type for any etl::queue instance.

The memory model determines the type used internally for indexes and size, to allow for the most efficient
implementation for the application.

Maximum queue sizes:
MEMORY_MODEL_SMALL   255
MEMORY_MODEL_MEDIUM  65535
MEMORY_MODEL_LARGE   2147483647
MEMORY_MODEL_HUGE    9223372036854775807

See memory_model.h

Member types

value_type      T
size_type       <based on memory model>
pointer         value_type*
const_pointer   const value_type*
reference       value_type&
const_reference const value_type&

Constructor

etl::queue<typename T, const size_t SIZE>();

Element access

T& front()
const T& front() const
Returns a reference or const reference to the first element.

T& back()
const T& back() const
Returns a reference or const reference to the last element.

Capacity

bool empty() const
Returns true if the size of the queue is zero, otherwise false.

bool full() const
Returns true if the size of the queue is SIZE, otherwise false.

size_type size() const
Returns the size of the queue.

size_type available() const
Returns the remaining available capacity in the queue.

ETL_CONSTEXPR size_type max_size() const
Returns the maximum possible size of the queue.

ETL_CONSTEXPR size_type capacity() const
Returns the maximum possible size of the queue.

Modifiers

void push(parameter_t value);
T& push();
Pushes a value to the back of the queue.
The first pushes a value.
The second allocates the new element but does not initialise it and returns a reference to it..
Emits an etl::queue_full if the queue is full and ETL_CHECK_PUSH_POP is defined. If the queue is full then emits an
etl::queue_full error. If asserts or exceptions are not enabled then undefined behaviour occurs.

void emplace(const T1& value1);
void emplace(const T1& value1, const T2& value2);
void emplace(const T1& value1, const T2& value2, const T3& value3);
void emplace(const T1& value1, const T2& value2, const T3& value3, const T4& value4);
Constructs an item in the the queue 'in place'.
Supports up to four constructor parameters.
Emits an etl::queue_full if the queue is full and ETL_CHECK_PUSH_POP is defined. If the queue is full then emits an
etl::queue_full error. If asserts or exceptions are not enabled then undefined behaviour occurs.

void pop();
Pop a value from the front of the list.
Emits an etl::queue_empty if the queue is empty and ETL_CHECK_PUSH_POP is defined. Undefined behaviour if the
queue is empty.

void pop_into(TContainer& destination);
Pop a value from the front of the list and places it in destination.
Emits an etl::queue_empty if the queue is empty and ETL_CHECK_PUSH_POP is defined. Undefined behaviour if the
queue is empty.

void clear();
Clears the queue to a size of zero.
queue.h