31#ifndef ETL_FORWARD_LIST_INCLUDED
32#define ETL_FORWARD_LIST_INCLUDED
47#include "static_assert.h"
194 while (p_node != ETL_NULLPTR)
197 p_node = p_node->next;
251 while (p_next != ETL_NULLPTR)
362 template <
typename T>
405 : p_node(ETL_NULLPTR)
415 : p_node(
other.p_node)
421 p_node = p_node->next;
428 p_node = p_node->next;
434 p_node =
other.p_node;
440 return iforward_list::data_cast(p_node)->value;
445 return &(iforward_list::data_cast(p_node)->value);
450 return &(iforward_list::data_cast(p_node)->value);
455 return lhs.p_node ==
rhs.p_node;
478 : p_node(ETL_NULLPTR)
493 : p_node(
other.p_node)
498 : p_node(
other.p_node)
504 p_node = p_node->next;
511 p_node = p_node->next;
517 p_node =
other.p_node;
523 return iforward_list::data_cast(p_node)->value;
528 return &(iforward_list::data_cast(p_node)->value);
533 return &(iforward_list::data_cast(p_node)->value);
538 return lhs.p_node ==
rhs.p_node;
551 typedef typename etl::iterator_traits<iterator>::difference_type difference_type;
630 return data_cast(*
get_head()).value;
638 return data_cast(*
get_head()).value;
646 template <
typename TIterator>
649#if ETL_IS_DEBUG_BUILD
650 difference_type
d = etl::distance(first, last);
659 while (first != last)
697#if defined(ETL_CHECK_PUSH_POP)
711#if defined(ETL_CHECK_PUSH_POP)
715 data_node_t&
data_node = allocate_data_node(etl::move(value));
720#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_FORWARD_LIST_FORCE_CPP03_IMPLEMENTATION)
724 template <
typename ... Args>
727#if defined(ETL_CHECK_PUSH_POP)
730 data_node_t* p_data_node = allocate_data_node();
731 ::new (&(p_data_node->value)) T(
etl::forward<Args>(args)...);
732 ETL_INCREMENT_DEBUG_COUNT;
742#if defined(ETL_CHECK_PUSH_POP)
747 ETL_INCREMENT_DEBUG_COUNT;
755 template <
typename T1>
758#if defined(ETL_CHECK_PUSH_POP)
763 ETL_INCREMENT_DEBUG_COUNT;
771 template <
typename T1,
typename T2>
774#if defined(ETL_CHECK_PUSH_POP)
779 ETL_INCREMENT_DEBUG_COUNT;
787 template <
typename T1,
typename T2,
typename T3>
790#if defined(ETL_CHECK_PUSH_POP)
794 ::new (&(
p_data_node->value))
T(value1, value2, value3);
795 ETL_INCREMENT_DEBUG_COUNT;
803 template <
typename T1,
typename T2,
typename T3,
typename T4>
806#if defined(ETL_CHECK_PUSH_POP)
810 ::new (&(
p_data_node->value))
T(value1, value2, value3, value4);
811 ETL_INCREMENT_DEBUG_COUNT;
822#if defined(ETL_CHECK_PUSH_POP)
897#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_FORWARD_LIST_FORCE_CPP03_IMPLEMENTATION)
901 template <
typename ...
Args>
908 ETL_INCREMENT_DEBUG_COUNT;
923 ETL_INCREMENT_DEBUG_COUNT;
932 template <
typename T1>
939 ETL_INCREMENT_DEBUG_COUNT;
948 template <
typename T1,
typename T2>
955 ETL_INCREMENT_DEBUG_COUNT;
964 template <
typename T1,
typename T2,
typename T3>
970 ::new (&(
p_data_node->value))
T(value1, value2, value3);
971 ETL_INCREMENT_DEBUG_COUNT;
980 template <
typename T1,
typename T2,
typename T3,
typename T4>
986 ::new (&(
p_data_node->value))
T(value1, value2, value3, value4);
987 ETL_INCREMENT_DEBUG_COUNT;
1001 for (
size_t i = 0
UL; !
full() && (
i <
n); ++
i)
1013 return to_iterator(position);
1019 template <
typename TIterator>
1022#if ETL_IS_DEBUG_BUILD
1023 difference_type
d = etl::distance(first, last);
1027 while (first != last)
1036 return to_iterator(position);
1051 remove_node_after(*position.p_node);
1070 remove_node_after(*position.p_node);
1082 if (first !=
end() && (first != last))
1101 if (p_next == ETL_NULLPTR)
1192 template <
typename TIsEqual>
1201 node_t* current = last->next;
1203 while (current != ETL_NULLPTR)
1206 if (
isEqual(data_cast(current)->value, data_cast(last)->value))
1208 remove_node_after(*last);
1216 current = last->next;
1254 template <
typename TCompare>
1348 p_tail.p_node->next = ETL_NULLPTR;
1369 void remove(
const T& value)
1391 template <
typename TPredicate>
1465 ETL_RESET_DEBUG_COUNT;
1473 while (
p_first != ETL_NULLPTR)
1491 ::new (&(p_node->value))
T(value);
1492 ETL_INCREMENT_DEBUG_COUNT;
1503 data_node_t* p_node = allocate_data_node();
1504 ::new (&(p_node->value))
T(
etl::move(value));
1505 ETL_INCREMENT_DEBUG_COUNT;
1527 this->start_node.next =
rhs.start_node.next;
1529 ETL_SET_DEBUG_COUNT(ETL_OBJECT_GET_DEBUG_COUNT(
rhs));
1531 ETL_OBJECT_RESET_DEBUG_COUNT(
rhs);
1532 rhs.start_node.next = ETL_NULLPTR;
1542 while (first != last)
1546 data_node_t& data_node = this->allocate_data_node(etl::move(*first));
1548 join(p_last_node, &data_node);
1549 data_node.next = ETL_NULLPTR;
1550 p_last_node = &data_node;
1565 static data_node_t* data_cast(node_t* p_node)
1567 return static_cast<data_node_t*
>(p_node);
1573 static data_node_t& data_cast(node_t& node)
1575 return static_cast<data_node_t&
>(node);
1581 static const data_node_t* data_cast(
const node_t* p_node)
1583 return static_cast<const data_node_t*
>(p_node);
1589 static const data_node_t& data_cast(
const node_t& node)
1591 return static_cast<const data_node_t&
>(node);
1597 void remove_node_after(node_t& node)
1600 node_t* p_node = node.next;
1602 if (p_node != ETL_NULLPTR)
1605 join(&node, p_node->next);
1608 destroy_data_node(
static_cast<data_node_t&
>(*p_node));
1617 data_node_t* (
etl::ipool::*func)() = &etl::ipool::allocate<data_node_t>;
1624 void destroy_data_node(data_node_t& node)
1628 ETL_DECREMENT_DEBUG_COUNT;
1637#if defined(ETL_POLYMORPHIC_FORWARD_LIST) || defined(ETL_POLYMORPHIC_CONTAINERS)
1654 iterator to_iterator(const_iterator itr)
const
1656 return iterator(
const_cast<node_t*
>(itr.p_node));
1664 template <
typename T, const
size_t MAX_SIZE_>
1669 ETL_STATIC_ASSERT((
MAX_SIZE_ > 0
U),
"Zero capacity etl::forward_list is not valid");
1671 static ETL_CONSTANT
size_t MAX_SIZE =
MAX_SIZE_;
1723 template <
typename TIterator>
1727 this->assign(first, last);
1730#if ETL_HAS_INITIALIZER_LIST
1737 this->assign(
init.begin(),
init.end());
1756 this->assign(
rhs.cbegin(),
rhs.cend());
1781 template <
typename T, const
size_t MAX_SIZE_>
1782 ETL_CONSTANT
size_t forward_list<T, MAX_SIZE_>::MAX_SIZE;
1787#if ETL_USING_CPP17 && ETL_HAS_INITIALIZER_LIST
1788 template <
typename... T>
1795#if ETL_USING_CPP11 && ETL_HAS_INITIALIZER_LIST
1796 template <
typename... T>
1807 template <
typename T>
1887 forward_list_ext(forward_list_ext&& other,
etl::ipool& node_pool)
1888 :
etl::iforward_list<T>(node_pool, node_pool.max_size(), true)
1890 this->move_container(etl::move(other));
1897 template <
typename TIterator>
1901 this->assign(first, last);
1904#if ETL_HAS_INITIALIZER_LIST
1911 this->assign(
init.begin(),
init.end());
1930 this->assign(
rhs.cbegin(),
rhs.cend());
1954 if (this->get_node_pool() != ETL_NULLPTR)
1959 this->set_node_pool(
pool);
1967 return *this->p_node_pool;
1977 template <
typename T>
1980 return (
lhs.size() ==
rhs.size()) &&
1981 etl::equal(
lhs.begin(),
lhs.end(),
rhs.begin());
1990 template <
typename T>
2003 template <
typename T>
2006 return etl::lexicographical_compare(
lhs.begin(),
lhs.end(),
rhs.begin(),
rhs.end());
2016 template <
typename T>
2029 template <
typename T>
2042 template <
typename T>
Template deduction guides.
Definition forward_list.h:1809
void set_pool(etl::ipool &pool)
Set the pool instance.
Definition forward_list.h:1951
etl::ipool & get_pool() const
Get the pool instance.
Definition forward_list.h:1965
forward_list_ext()
Default constructor.
Definition forward_list.h:1824
forward_list_ext(etl::ipool &node_pool)
Default constructor.
Definition forward_list.h:1832
forward_list_ext(size_t initial_size, const T &value, etl::ipool &node_pool)
Construct from size and value.
Definition forward_list.h:1850
forward_list_ext(TIterator first, TIterator last, etl::ipool &node_pool, typename etl::enable_if<!etl::is_integral< TIterator >::value, int >::type=0)
Construct from range.
Definition forward_list.h:1898
forward_list_ext(const forward_list_ext &other)
Copy constructor. Implicit pool.
Definition forward_list.h:1859
forward_list_ext(size_t initial_size, etl::ipool &node_pool)
Construct from size.
Definition forward_list.h:1841
forward_list_ext(const forward_list_ext &other, etl::ipool &node_pool)
Copy constructor. Explicit pool.
Definition forward_list.h:1868
~forward_list_ext()
Destructor.
Definition forward_list.h:1918
Definition forward_list.h:1666
~forward_list()
Destructor.
Definition forward_list.h:1744
forward_list(size_t initial_size, const T &value=T())
Construct from size and value.
Definition forward_list.h:1694
forward_list(const forward_list &other)
Copy constructor.
Definition forward_list.h:1703
forward_list()
Default constructor.
Definition forward_list.h:1685
forward_list(TIterator first, TIterator last, typename etl::enable_if<!etl::is_integral< TIterator >::value, int >::type=0)
Construct from range.
Definition forward_list.h:1724
const_iterator
Definition forward_list.h:472
iterator.
Definition forward_list.h:398
ETL_CONSTEXPR14 bool operator==(const etl::expected< TValue, TError > &lhs, const etl::expected< TValue2, TError2 > &rhs)
Equivalence operators.
Definition expected.h:968
#define ETL_ASSERT(b, e)
Definition error_handler.h:356
Definition exception.h:47
iterator end()
Gets the end of the forward_list.
Definition forward_list.h:596
void resize(size_t n)
Resizes the forward_list.
Definition forward_list.h:831
reference emplace_front(const T1 &value1)
Emplaces a value to the front of the list..
Definition forward_list.h:756
size_type MAX_SIZE
The maximum size of the forward_list.
Definition forward_list.h:353
void unique(TIsEqual isEqual)
Definition forward_list.h:1193
void assign(TIterator first, TIterator last, typename etl::enable_if<!etl::is_integral< TIterator >::value, int >::type=0)
Definition forward_list.h:647
iforward_list & operator=(const iforward_list &rhs)
Assignment operator.
Definition forward_list.h:1414
iterator emplace_after(const_iterator position, const T1 &value1)
Emplaces a value to the forward_list after the specified position.
Definition forward_list.h:933
forward_list_base(bool pool_is_shared_)
The constructor that is called from derived classes.
Definition forward_list.h:268
reference emplace_front(const T1 &value1, const T2 &value2, const T3 &value3)
Emplaces a value to the front of the list..
Definition forward_list.h:788
const_iterator cbegin() const
Gets the beginning of the forward_list.
Definition forward_list.h:588
iterator before_begin()
Gets before the beginning of the forward_list.
Definition forward_list.h:572
iterator erase_after(iterator position)
Erases the value at the specified position.
Definition forward_list.h:1042
void insert_node_after(node_t &position, node_t &node)
Insert a node.
Definition forward_list.h:311
iterator erase_after(const_iterator position)
Erases the value at the specified position.
Definition forward_list.h:1061
iterator emplace_after(const_iterator position, const T1 &value1, const T2 &value2, const T3 &value3, const T4 &value4)
Emplaces a value to the forward_list after the specified position.
Definition forward_list.h:981
void unique()
Definition forward_list.h:1183
node_t start_node
The node that acts as the forward_list start.
Definition forward_list.h:351
iterator insert_after(const_iterator position, size_t n, const T &value)
Inserts 'n' copies of a value to the forward_list after the specified position.
Definition forward_list.h:997
size_type max_size() const
Gets the maximum possible size of the forward_list.
Definition forward_list.h:169
forward_list_base(etl::ipool &node_pool_, size_type max_size_, bool pool_is_shared_)
The constructor that is called from derived classes.
Definition forward_list.h:278
reference emplace_front(const T1 &value1, const T2 &value2, const T3 &value3, const T4 &value4)
Emplaces a value to the front of the list..
Definition forward_list.h:804
void resize(size_t n, T value)
Definition forward_list.h:841
iforward_list(etl::ipool &node_pool, size_t max_size_, bool pool_is_shared_)
Constructor.
Definition forward_list.h:1449
size_t available() const
Definition forward_list.h:229
ETL_DECLARE_DEBUG_COUNT
Internal debugging.
Definition forward_list.h:355
size_type capacity() const
Gets the maximum possible size of the forward_list.
Definition forward_list.h:177
void clear()
Clears the forward_list.
Definition forward_list.h:620
iterator emplace_after(const_iterator position)
Emplaces a value to the forward_list after the specified position.
Definition forward_list.h:917
iterator emplace_after(const_iterator position, const T1 &value1, const T2 &value2)
Emplaces a value to the forward_list after the specified position.
Definition forward_list.h:949
node_t * get_head()
Get the head node.
Definition forward_list.h:295
const_iterator before_begin() const
Gets before the beginning of the forward_list.
Definition forward_list.h:580
etl::ipool * get_node_pool()
Get the node pool instance.
Definition forward_list.h:346
void reverse()
Reverses the forward_list.
Definition forward_list.h:238
const_iterator cend() const
Gets the end of the forward_list.
Definition forward_list.h:612
const_iterator begin() const
Gets the beginning of the forward_list.
Definition forward_list.h:564
void join(node_t *left, node_t *right)
Join two nodes.
Definition forward_list.h:329
size_t size_type
The type used for determining the size of forward_list.
Definition forward_list.h:156
reference front()
Gets a reference to the first element.
Definition forward_list.h:628
void move_after(const_iterator first_before, const_iterator last, const_iterator to_before)
Definition forward_list.h:1144
bool pool_is_shared
If true then the pool is shared between lists.
Definition forward_list.h:354
void push_front(const T &value)
Pushes a value to the front of the forward_list.
Definition forward_list.h:695
iterator insert_after(const_iterator position, const T &value)
Inserts a value to the forward_list after the specified position.
Definition forward_list.h:887
reference emplace_front(const T1 &value1, const T2 &value2)
Emplaces a value to the front of the list..
Definition forward_list.h:772
iterator emplace_after(const_iterator position, const T1 &value1, const T2 &value2, const T3 &value3)
Emplaces a value to the forward_list after the specified position.
Definition forward_list.h:965
void sort()
Definition forward_list.h:1224
void sort(TCompare compare)
Definition forward_list.h:1255
void initialise()
Initialise the forward_list.
Definition forward_list.h:1457
etl::ipool * p_node_pool
The pool of data nodes used in the list.
Definition forward_list.h:352
const_reference front() const
Gets a const reference to the first element.
Definition forward_list.h:636
void remove_if(TPredicate predicate)
Removes according to a predicate.
Definition forward_list.h:1392
bool has_shared_pool() const
true if the list has a shared pool.
Definition forward_list.h:161
bool full() const
Checks to see if the forward_list is full.
Definition forward_list.h:219
void pop_front()
Removes a value from the front of the forward_list.
Definition forward_list.h:820
iterator insert_after(const_iterator position, TIterator first, TIterator last, typename etl::enable_if<!etl::is_integral< TIterator >::value, int >::type=0)
Inserts a range of values to the forward_list after the specified position.
Definition forward_list.h:1020
~forward_list_base()
Destructor.
Definition forward_list.h:288
iterator erase_after(const_iterator first, const_iterator last)
Erases a range of elements.
Definition forward_list.h:1080
bool empty() const
Checks to see if the forward_list is empty.
Definition forward_list.h:211
void assign(size_t n, const T &value)
Assigns 'n' copies of a value to the forward_list.
Definition forward_list.h:674
void set_node_pool(etl::ipool &node_pool_)
Set the node pool instance.
Definition forward_list.h:337
void move_after(const_iterator from_before, const_iterator to_before)
Definition forward_list.h:1120
~iforward_list()
Destructor.
Definition forward_list.h:1644
reference emplace_front()
Emplaces a value to the front of the list..
Definition forward_list.h:740
size_type size() const
Gets the size of the forward_list.
Definition forward_list.h:185
data_node_t & allocate_data_node(const_reference value)
Allocate a data_node_t.
Definition forward_list.h:1488
const_iterator end() const
Gets the end of the forward_list.
Definition forward_list.h:604
iterator begin()
Gets the beginning of the forward_list.
Definition forward_list.h:556
iforward_list(bool pool_is_shared_)
Constructor.
Definition forward_list.h:1441
const node_t * get_head() const
Get the head node.
Definition forward_list.h:303
bool is_trivial_list() const
Is the forward_list a trivial length?
Definition forward_list.h:321
Definition forward_list.h:138
Definition forward_list.h:96
Definition forward_list.h:68
Definition forward_list.h:82
Definition forward_list.h:110
Definition forward_list.h:364
Definition forward_list.h:124
size_t size() const
Returns the number of allocated items in the pool.
Definition ipool.h:301
void release_all()
Release all objects in the pool.
Definition ipool.h:248
bool full() const
Definition ipool.h:319
size_t max_size() const
Returns the maximum number of items in the pool.
Definition ipool.h:269
void release(const void *const p_object)
Definition ipool.h:239
size_t available() const
Returns the number of free items in the pool.
Definition ipool.h:293
enable_if
Definition type_traits_generator.h:1186
is_integral
Definition type_traits_generator.h:996
bitset_ext
Definition absolute.h:38
bool operator>(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:693
size_t max_size() const
Returns the maximum number of items in the variant_pool.
Definition variant_pool_generator.h:395
bool operator>=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:705
bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:654
bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:642
bool operator<(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:666
bool operator<=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:681
The node element in the forward_list.
Definition forward_list.h:145
The data node element in the forward_list.
Definition forward_list.h:384
Definition type_traits_generator.h:2096
iterator
Definition iterator.h:399
pair holds two objects of arbitrary type
Definition utility.h:164