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

list

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

etl::list<typename T, const size_t SIZE>

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

Note: Does not support the member function swap

Member types

value_type              T
size_type               std::size_t
difference_type         std::ptrdiff_t
reference               value_type&
const_reference         const value_type&
pointer                 value_type*
const_pointer           const value_type*
iterator                Bi-directional iterator
const_iterator          Constant bi-directional iterator
reverse_iterator        std::reverse_iterator<iterator>
const_reverse_iterator  std::reverse_iterator<const_iterator>

Constructor

etl::list<typename T, const size_t SIZE>();
etl::list<typename T, const size_t SIZE>(size_t initialSize, parameter_t value = T());
template <typename TIterator>
etl::list<typename T, const size_t SIZE>(TIterator begin, TIterator end);
Default or copy constructs SIZE elements, regardless of the initial 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.

Iterators

iterator begin()
const_iterator begin() const
const_iterator cbegin() const
Returns an iterator to the beginning of the list.

iterator end()
const_iterator end() const
const_iterator cend() const
Returns an iterator to the end of the list.

reverse_iterator rbegin()
const_reverse_iterator rbegin() const
const_reverse_iterator crbegin() const
Returns a reverse iterator to the beginning of the list.

reverse_iterator rend()
const_reverse_iterator rend() const
const_reverse_iterator crend() const
Returns a reverse iterator to the end of the list.

Capacity

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

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

size_t size() const
Returns the size of the list.

size_t available() const
Returns the remaining available capacity in the list.

size_t max_size() const
Returns the maximum possible size of the list .

Modifiers

template <typename TIterator>
void assign(TIterator begin, TIterator end);
void assign(size_t n, parameter_t value);
Fills the list with the values.

void push_front(parameter_t value);
void push_front();
Pushes a value to the front of the list. The first pushes a value, the second allocates the new element but does not
initialise it. If the list is full then emits an etl::list_full error.

void push_back(parameter_t value);
void push_back();
Pushes a value to the back of the list. The first pushes a value, the second allocates the new element but does not
initialise it. If the list is full then emits an etl::list_full exception.

void pop_front();
Pop a value from the front of the list.

void pop_back();
Pop a value from the back of the list.

template <typename TIterator>
void insert(iterator position, TIterator begin, TIterator end);

iterator insert(iterator position, parameter_t value);
void insert(iterator position, size_t n, parameter_t value);
Inserts values in to the list. If the list is full then emits an etl::list_full error.

template <typename TIterator>
iterator erase(TIterator begin, TIterator end);

iterator erase(iterator position);
Erases values in the list.

void resize(size_t n);
void resize(size_t n, parameter_t value);
Resizes the list. If the new size is larger then the first assigns default constructed values, the second assigns the supplied
value.

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

void splice(iterator to, ilist& other);
Moves the elements in list other to before the position to.
The operation performs copies between the different lists.

void splice(iterator to, ilist& other, iterator from);
Moves the element at position from in list other to before the position to.
The operation is fast when spicing within the same list, otherwise performs copies between different lists.

void splice(iterator to, ilist& other, iterator first, iterator last);
Moves the elements in the range first to one before last in list other to before the position to.
The operation is fast when spicing within the same list, otherwise performs copies between different lists.

void merge(ilist& other);
Merges the elements in list other to this list.
The lists must be sorted.

template <typename TCompare>
void merge(ilist& other, TCompare compare);
Merges the elements in list other to this list using the supplied comparison function to determine order.
The lists must already be sorted according to the compare function.

Operations

void remove(const T& value);
Removes from the container all the elements that compare equal to value.

template <typename TPredicate>
void remove_if(TPredicate predicate);
Removes from the container all the elements that satisfy predicate.

void unique();
template <typename TPredicate>
void unique(TPredicate predicate);
The first version removes all but the first element from every group of consecutive elements.
The second removes all but the first element from every group of consecutive elements that satisfy the binary predicate.

void sort();
template <typename TCompare>
void sort(TCompare compare);
The first version sorts using the < operator.
The second uses the supplied compare function.

void reverse();
Reverses the order of the list.

Non-member functions

==  true if the contents of the lists are equal, otherwise false.
!=  true if the contents of the lists are not equal, otherwise false.
<   true if the contents of the lhs are lexicographically less than the contents of the rhs,  otherwise false.
<=  true if the contents of the lhs are lexicographically less than or equal to the contents of the rhs, otherwise false.
>   true if the contents of the lhs are lexicographically greater than the contents of the rhs,  otherwise false.
>=  true if the contents of the lhs are lexicographically greater than or equal to the contents of the rhs, otherwise
false.

list.h