31#ifndef ETL_LIST_INCLUDED
32#define ETL_LIST_INCLUDED
46#include "static_assert.h"
166 : previous(ETL_NULLPTR),
176 using ETL_OR_STD::swap;
178 swap(previous, next);
208 p_node->previous = p_node->next;
210 p_node = p_node->previous;
215 p_node->previous = p_node->next;
250 p_node = p_node->next;
346 right.previous = &left;
406 template <
typename T>
411 typedef T value_type;
413 typedef const T* const_pointer;
414 typedef T& reference;
415 typedef const T& const_reference;
419 typedef size_t size_type;
451 static data_node_t& data_cast(node_t&
node)
453 return reinterpret_cast<data_node_t&
>(
node);
459 static const data_node_t* data_cast(
const node_t* p_node)
461 return reinterpret_cast<const data_node_t*
>(p_node);
467 static const data_node_t& data_cast(
const node_t&
node)
469 return reinterpret_cast<const data_node_t&
>(
node);
485 : p_node(ETL_NULLPTR)
495 : p_node(
other.p_node)
501 p_node = p_node->next;
508 p_node = p_node->next;
514 p_node = p_node->previous;
521 p_node = p_node->previous;
527 p_node =
other.p_node;
531 reference operator *()
const
533 return ilist::data_cast(p_node)->value;
536 pointer operator &()
const
538 return &(ilist::data_cast(p_node)->value);
541 pointer operator ->()
const
543 return &(ilist::data_cast(p_node)->value);
548 return lhs.p_node ==
rhs.p_node;
571 : p_node(ETL_NULLPTR)
586 : p_node(
other.p_node)
591 : p_node(
other.p_node)
597 p_node = p_node->next;
604 p_node = p_node->next;
610 p_node = p_node->previous;
617 p_node = p_node->previous;
623 p_node =
other.p_node;
627 const_reference operator *()
const
629 return ilist::data_cast(p_node)->value;
632 const_pointer operator &()
const
634 return &(ilist::data_cast(p_node)->value);
637 const_pointer operator ->()
const
639 return &(ilist::data_cast(p_node)->value);
644 return lhs.p_node ==
rhs.p_node;
657 typedef typename etl::iterator_traits<iterator>::difference_type difference_type;
659 typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
660 typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
731 return reverse_iterator(
get_head());
737 const_reverse_iterator
rend()
const
739 return const_reverse_iterator(
get_head());
753 const_reverse_iterator
crend()
const
755 return const_reverse_iterator(
get_head());
795 template <
typename TIterator>
798#if ETL_IS_DEBUG_BUILD
799 difference_type d = etl::distance(first, last);
806 while (first != last)
820#if ETL_IS_DEBUG_BUILD
840 ETL_ASSERT_CHECK_PUSH_POP_OR_RETURN(!
full(), ETL_ERROR(
list_full));
851 ETL_ASSERT_CHECK_PUSH_POP_OR_RETURN(!
full(), ETL_ERROR(
list_full));
857#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_LIST_FORCE_CPP03_IMPLEMENTATION)
861 template <
typename ...
Args>
865 ETL_ASSERT_CHECK_PUSH_POP(!
full(), ETL_ERROR(list_full));
871 ETL_INCREMENT_DEBUG_COUNT;
887 ETL_INCREMENT_DEBUG_COUNT;
895 template <
typename T1>
904 ETL_INCREMENT_DEBUG_COUNT;
912 template <
typename T1,
typename T2>
921 ETL_INCREMENT_DEBUG_COUNT;
929 template <
typename T1,
typename T2,
typename T3>
938 ETL_INCREMENT_DEBUG_COUNT;
946 template <
typename T1,
typename T2,
typename T3,
typename T4>
955 ETL_INCREMENT_DEBUG_COUNT;
977 ETL_ASSERT_CHECK_PUSH_POP_OR_RETURN(!
full(), ETL_ERROR(
list_full));
988 ETL_ASSERT_CHECK_PUSH_POP_OR_RETURN(!
full(), ETL_ERROR(
list_full));
997#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT
998 template <
typename ...
Args>
1001 ETL_ASSERT_CHECK_PUSH_POP(!
full(), ETL_ERROR(list_full));
1007 ETL_INCREMENT_DEBUG_COUNT;
1020 ETL_INCREMENT_DEBUG_COUNT;
1025 template <
typename T1>
1034 ETL_INCREMENT_DEBUG_COUNT;
1048 ETL_INCREMENT_DEBUG_COUNT;
1062 ETL_INCREMENT_DEBUG_COUNT;
1076 ETL_INCREMENT_DEBUG_COUNT;
1114 data_node_t&
data_node = allocate_data_node(etl::move(value));
1124#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_LIST_FORCE_CPP03_IMPLEMENTATION)
1125 template <
typename ...
Args>
1133 ETL_INCREMENT_DEBUG_COUNT;
1146 ETL_INCREMENT_DEBUG_COUNT;
1152 template <
typename T1>
1160 ETL_INCREMENT_DEBUG_COUNT;
1174 ETL_INCREMENT_DEBUG_COUNT;
1188 ETL_INCREMENT_DEBUG_COUNT;
1202 ETL_INCREMENT_DEBUG_COUNT;
1214 for (
size_t i = 0
UL; i <
n; ++i)
1219 insert_node(*to_iterator(position).p_node, allocate_data_node(value));
1226 template <
typename TIterator>
1229 while (first != last)
1234 insert_node(*to_iterator(position).p_node, allocate_data_node(*first));
1247 remove_node(*
position_.p_node->previous);
1298 else if (
n <
size())
1305 else if (
n >
size())
1322 void remove(const_reference value)
1342 template <
typename TPredicate>
1373 template <
typename TIsEqual>
1420 while (itr !=
other.end())
1477 move(
to, first, last);
1483 other.erase(first, last);
1496 move(
to, first, last);
1501 ilist::iterator itr = first;
1509 other.erase(first, last);
1525 template <
typename TCompare>
1530#if ETL_IS_DEBUG_BUILD
1582 template <
typename TCompare>
1587#if ETL_IS_DEBUG_BUILD
1666 template <
typename TCompare>
1798 while (itr !=
rhs.end())
1842 ETL_RESET_DEBUG_COUNT;;
1877 join(terminal_node,
rhs.get_head());
1880 ETL_SET_DEBUG_COUNT(ETL_OBJECT_GET_DEBUG_COUNT(
rhs));
1883 ETL_OBJECT_RESET_DEBUG_COUNT(
rhs);
1884 rhs.join(
rhs.terminal_node,
rhs.terminal_node);
1892 while (first != last)
1913 void move(iterator
to, iterator
from)
1935 void move(iterator
to, iterator first, iterator last)
1937 if ((first ==
to) || (last ==
to))
1942#if ETL_IS_DEBUG_BUILD
1944 for (const_iterator
item = first;
item != last; ++
item)
1966 void remove_node(node_t&
node)
1972 destroy_data_node(
static_cast<data_node_t&
>(
node));
1978 data_node_t& allocate_data_node(const_reference value)
1984 ETL_INCREMENT_DEBUG_COUNT;
1999 ETL_INCREMENT_DEBUG_COUNT;
2008 data_node_t* allocate_data_node()
2010 data_node_t* (
etl::ipool::*
func)() = &etl::ipool::allocate<data_node_t>;
2017 void destroy_data_node(data_node_t&
node)
2022 ETL_DECREMENT_DEBUG_COUNT;
2026 ilist(
const ilist&);
2028#if defined(ETL_POLYMORPHIC_LIST) || defined(ETL_POLYMORPHIC_CONTAINERS)
2045 iterator to_iterator(const_iterator itr)
const
2047 return iterator(*(
const_cast<node_t*
>(itr.p_node)));
2054 template <
typename T, const
size_t MAX_SIZE_>
2059 ETL_STATIC_ASSERT((MAX_SIZE_ > 0U),
"Zero capacity etl::list is not valid");
2061 static ETL_CONSTANT
size_t MAX_SIZE = MAX_SIZE_;
2065 typedef T value_type;
2067 typedef const T* const_pointer;
2068 typedef T& reference;
2069 typedef const T& const_reference;
2071 typedef T&& rvalue_reference;
2073 typedef size_t size_type;
2079 :
etl::
ilist<T>(node_pool, MAX_SIZE, false)
2095 :
etl::
ilist<T>(node_pool, MAX_SIZE, false)
2097 this->assign(initial_size, T());
2103 list(
size_t initial_size,
const T& value)
2104 :
etl::
ilist<T>(node_pool, MAX_SIZE, false)
2106 this->assign(initial_size, value);
2113 :
etl::
ilist<T>(node_pool, MAX_SIZE, false)
2126 :
etl::
ilist<T>(node_pool, MAX_SIZE, false)
2133 while (itr != other.end())
2135 this->push_back(etl::move(*itr));
2147 template <
typename TIterator>
2149 :
ilist<T>(node_pool, MAX_SIZE, false)
2151 this->assign(first, last);
2154#if ETL_HAS_INITIALIZER_LIST
2158 list(std::initializer_list<T> init)
2159 :
ilist<T>(node_pool, MAX_SIZE, false)
2161 this->assign(init.begin(), init.end());
2184 this->move_container(etl::move(rhs));
2196 template <
typename T, const
size_t MAX_SIZE_>
2197 ETL_CONSTANT
size_t list<T, MAX_SIZE_>::MAX_SIZE;
2202#if ETL_USING_CPP17 && ETL_HAS_INITIALIZER_LIST
2203 template <
typename...
T>
2211#if ETL_USING_CPP11 && ETL_HAS_INITIALIZER_LIST
2212 template <
typename...
T>
2222 template <
typename T>
2227 typedef T value_type;
2229 typedef const T* const_pointer;
2230 typedef T& reference;
2231 typedef const T& const_reference;
2232 typedef size_t size_type;
2266 this->assign(initial_size, T());
2275 this->assign(initial_size, value);
2309 this->move_container(etl::move(other));
2315 list_ext(list_ext&& other,
etl::ipool& node_pool)
2316 :
etl::ilist<T>(node_pool, node_pool.max_size(), true)
2318 this->move_container(etl::move(other));
2325 template <
typename TIterator>
2329 this->assign(first, last);
2332#if ETL_HAS_INITIALIZER_LIST
2339 this->assign(init.begin(), init.end());
2362 this->move_container(etl::move(rhs));
2374 if (this->get_node_pool() != ETL_NULLPTR)
2379 this->set_node_pool(
pool);
2387 return *this->p_node_pool;
2397 template <
typename T>
2400 return (
lhs.size() ==
rhs.size()) && etl::equal(
lhs.begin(),
lhs.end(),
rhs.begin());
2409 template <
typename T>
2422 template <
typename T>
2425 return etl::lexicographical_compare(
lhs.begin(),
lhs.end(),
rhs.begin(),
rhs.end());
2435 template <
typename T>
2448 template <
typename T>
2461 template <
typename T>
const_iterator
Definition list.h:565
iterator.
Definition list.h:478
Template deduction guides.
Definition list.h:2224
list_ext(const list_ext &other, etl::ipool &node_pool)
Copy constructor. Explicit pool.
Definition list.h:2293
list_ext(size_t initial_size, etl::ipool &node_pool)
Construct from size.
Definition list.h:2263
void set_pool(etl::ipool &pool)
Set the pool instance.
Definition list.h:2371
list_ext(size_t initial_size, const T &value, etl::ipool &node_pool)
Construct from size and value.
Definition list.h:2272
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 list.h:2326
list_ext()
Default constructor.
Definition list.h:2239
etl::ipool & get_pool() const
Get the pool instance.
Definition list.h:2385
list_ext(etl::ipool &node_pool)
Default constructor.
Definition list.h:2247
~list_ext()
Destructor.
Definition list.h:2255
list_ext(const list_ext &other)
Copy constructor. Implicit pool.
Definition list.h:2281
A templated list implementation that uses a fixed size buffer.
Definition list.h:2056
~list()
Destructor.
Definition list.h:2086
list(const list &other)
Copy constructor.
Definition list.h:2112
list(size_t initial_size, const T &value)
Construct from size and value.
Definition list.h:2103
list(TIterator first, TIterator last, typename etl::enable_if<!etl::is_integral< TIterator >::value, int >::type=0)
Construct from range.
Definition list.h:2148
list(size_t initial_size)
Construct from size.
Definition list.h:2094
list()
Default constructor.
Definition list.h:2078
ETL_CONSTEXPR14 bool operator==(const etl::expected< TValue, TError > &lhs, const etl::expected< TValue2, TError2 > &rhs)
Equivalence operators.
Definition expected.h:962
ETL_NODISCARD ETL_CONSTEXPR14 bool is_sorted(TIterator begin, TIterator end)
Definition algorithm.h:1709
#define ETL_ASSERT(b, e)
Definition error_handler.h:356
Definition exception.h:47
ilist(etl::ipool &node_pool, size_t max_size_, bool pool_is_shared_)
Constructor.
Definition list.h:1824
const_reverse_iterator rend() const
Gets the reverse end of the list.
Definition list.h:737
void clear()
Clears the list.
Definition list.h:1314
const_iterator cbegin() const
Gets the beginning of the list.
Definition list.h:697
iterator end()
Gets the end of the list.
Definition list.h:681
void push_back(const T &value)
Pushes a value to the back of the list.
Definition list.h:975
iterator emplace(const_iterator position)
Emplaces a value to the list at the specified position.
Definition list.h:1139
ilist(bool pool_is_shared_)
Constructor.
Definition list.h:1816
reference back()
Gets a reference to the last element.
Definition list.h:777
size_t size_type
The type used for determining the size of list.
Definition list.h:155
void reverse()
Reverses the list.
Definition list.h:196
const_reverse_iterator crend() const
Gets the reverse end of the list.
Definition list.h:753
reference emplace_front(const T1 &value1)
Emplaces a value to the front of the list.
Definition list.h:896
void splice(iterator to, ilist &other, iterator from)
Splices an element from another list to this.
Definition list.h:1434
size_type size() const
Gets the size of the list.
Definition list.h:238
void sort(TCompare compare)
Definition list.h:1667
size_type available() const
Definition list.h:282
void splice(iterator to, ilist &other, iterator first, iterator last)
Splices a range of elements from another list to this.
Definition list.h:1472
void join(node_t &left, node_t &right)
Join two nodes.
Definition list.h:343
void insert(const_iterator position, size_t n, const_reference value)
Inserts 'n' copies of a value to the list at the specified position.
Definition list.h:1212
void unique(TIsEqual isEqual)
Definition list.h:1374
void insert(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 list at the specified position.
Definition list.h:1227
const_reverse_iterator rbegin() const
Gets the reverse beginning of the list.
Definition list.h:721
list_base(bool pool_is_shared_)
The constructor that is called from derived classes.
Definition list.h:352
etl::ipool * p_node_pool
The pool of data nodes used in the list.
Definition list.h:395
size_type max_size() const
Gets the maximum possible size of the list.
Definition list.h:222
void resize(size_t n)
Resizes the list.
Definition list.h:1280
list_base(etl::ipool &node_pool_, size_type max_size_, bool pool_is_shared_)
The constructor that is called from derived classes.
Definition list.h:363
bool full() const
Checks to see if the list is full.
Definition list.h:272
reverse_iterator rend()
Gets the reverse end of the list.
Definition list.h:729
reverse_iterator rbegin()
Gets the reverse beginning of the list.
Definition list.h:713
reference emplace_front()
Emplaces a value to the front of the list.
Definition list.h:879
ilist & operator=(const ilist &rhs)
Assignment operator.
Definition list.h:1777
iterator insert(const_iterator position, const_reference value)
Inserts a value to the list at the specified position.
Definition list.h:1096
size_type MAX_SIZE
The maximum size of the list.
Definition list.h:397
node_t terminal_node
The node that acts as the list start and end.
Definition list.h:396
void push_front(const T &value)
Pushes a value to the front of the list.
Definition list.h:838
void initialise()
Initialise the list.
Definition list.h:1832
bool pool_is_shared
If true then the pool is shared between lists.
Definition list.h:398
void splice(iterator to, ilist &other)
Splices from another list to this.
Definition list.h:1402
const_iterator end() const
Gets the end of the list.
Definition list.h:689
ETL_DECLARE_DEBUG_COUNT
Internal debugging.
Definition list.h:399
reference front()
Gets a reference to the first element.
Definition list.h:761
void pop_front()
Removes a value from the front of the list.
Definition list.h:964
const_iterator begin() const
Gets the beginning of the list.
Definition list.h:673
void merge(ilist &other)
Merge another list into this one. Both lists should be sorted.
Definition list.h:1517
bool is_trivial_list() const
Is the list a trivial length?
Definition list.h:293
void assign(size_t n, const T &value)
Assigns 'n' copies of a value to the list.
Definition list.h:818
iterator erase(const_iterator first, const_iterator last)
Erases a range of elements.
Definition list.h:1254
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 list.h:947
void set_node_pool(etl::ipool &node_pool_)
Set the node pool instance.
Definition list.h:374
reference emplace_front(const T1 &value1, const T2 &value2, const T3 &value3)
Emplaces a value to the front of the list.
Definition list.h:930
void merge(ilist &other, TCompare compare)
Merge another list into this one. Both lists should be sorted.
Definition list.h:1526
void resize(size_t n, const_reference value)
Resizes the list.
Definition list.h:1288
size_type capacity() const
Gets the maximum possible size of the list.
Definition list.h:230
reference emplace_back()
Emplaces a value to the back of the list.
Definition list.h:1012
bool empty() const
Checks to see if the list is empty.
Definition list.h:264
etl::ipool * get_node_pool()
Get the node pool instance.
Definition list.h:383
iterator begin()
Gets the beginning of the list.
Definition list.h:665
void sort()
Definition list.h:1636
const_reference back() const
Gets a reference to the last element.
Definition list.h:785
void unique()
Definition list.h:1364
const_reference front() const
Gets a const reference to the first element.
Definition list.h:769
node_t & get_head()
Get the head node.
Definition list.h:301
const node_t & get_head() const
Get the head node.
Definition list.h:309
void insert_node(node_t &position, node_t &node)
Insert a node before 'position'.
Definition list.h:333
const node_t & get_tail() const
Get the tail node.
Definition list.h:325
const_iterator cend() const
Gets the end of the list.
Definition list.h:705
const_reverse_iterator crbegin() const
Gets the reverse beginning of the list.
Definition list.h:745
~list_base()
Destructor.
Definition list.h:391
void remove_if(TPredicate predicate)
Removes according to a predicate.
Definition list.h:1343
void assign(TIterator first, TIterator last, typename etl::enable_if<!etl::is_integral< TIterator >::value, int >::type=0)
Definition list.h:796
node_t & get_tail()
Get the tail node.
Definition list.h:317
iterator erase(const_iterator position)
Erases the value at the specified position.
Definition list.h:1242
bool has_shared_pool() const
true if the list has a shared pool.
Definition list.h:188
void pop_back()
Removes a value from the back of the list.
Definition list.h:1085
reference emplace_front(const T1 &value1, const T2 &value2)
Emplaces a value to the front of the list.
Definition list.h:913
size_t size() const
Returns the number of allocated items in the pool.
Definition ipool.h:504
void release_all()
Release all objects in the pool.
Definition ipool.h:451
bool full() const
Definition ipool.h:522
size_t max_size() const
Returns the maximum number of items in the pool.
Definition ipool.h:472
void release(const void *const p_object)
Definition ipool.h:442
size_t available() const
Returns the number of free items in the pool.
Definition ipool.h:496
enable_if
Definition type_traits_generator.h:1254
is_integral
Definition type_traits_generator.h:1064
bitset_ext
Definition absolute.h:39
ETL_CONSTEXPR14 void swap(etl::typed_storage_ext< T > &lhs, etl::typed_storage_ext< T > &rhs) ETL_NOEXCEPT
Swap two etl::typed_storage_ext.
Definition alignment.h:838
bool operator>(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1190
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:1202
bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1151
bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1139
ETL_NODISCARD ETL_CONSTEXPR14 T round_half_even_unscaled(T value) ETL_NOEXCEPT
Definition scaled_rounding.h:315
bool operator<(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1163
bool operator<=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1178
Definition functional.h:274
The data node element in the list.
Definition list.h:429
Definition type_traits_generator.h:2237
iterator
Definition iterator.h:399
Definition functional.h:170
The node element in the list.
Definition list.h:161
void reverse()
Reverses the previous & next pointers.
Definition list.h:174
node_t()
Constructor.
Definition list.h:165
etl::conditional< etl::is_fundamental< T >::value||etl::is_pointer< T >::value, T, constT & >::type type
By default fundamental and pointer types are passed by value.
Definition parameter_type.h:48