31#ifndef ETL_INTRUSIVE_FORWARD_LIST_INCLUDED
32#define ETL_INTRUSIVE_FORWARD_LIST_INCLUDED
138 template <
typename TLink>
144 typedef TLink link_type;
156 link_type* p_next =
p_unlink->etl_next;
168 template <
typename TIterator>
171#if ETL_IS_DEBUG_BUILD
172 intmax_t d = etl::distance(first, last);
181 while (first != last)
183 link_type& value = *first++;
187 value.etl_next =
p_last->etl_next;
188 p_last->etl_next = &value;
209#if defined(ETL_CHECK_PUSH_POP)
226 link_type* current =
start.etl_next;
227 link_type* next =
start.etl_next;
231 next = next->etl_next;
232 current->etl_next = previous;
302 return (
size() <= 1U);
320 link_type* p_next = link.etl_next;
322 if (p_next != &this->terminator)
338 return start.etl_next;
346 return start.etl_next;
367 while (
p_link != ETL_NULLPTR)
388 link_type* result = ETL_NULLPTR;
394 link_type* p_next = link->etl_next;
398 if (p_next != &this->terminator)
422 link_type* p_next =
p_unlink->etl_next;
427 if (
p_after == &this->terminator)
438 template <
typename TLink>
446 template <
typename TValue,
typename TLink>
452 typedef typename etl::intrusive_forward_list_base<TLink>::link_type link_type;
455 typedef TValue value_type;
456 typedef value_type* pointer;
457 typedef const value_type* const_pointer;
458 typedef value_type& reference;
459 typedef const value_type& const_reference;
460 typedef size_t size_type;
477 : p_value(ETL_NULLPTR)
482 : p_value(
other.p_value)
489 p_value = p_value->etl_next;
497 p_value = p_value->etl_next;
503 p_value =
other.p_value;
507 reference operator *()
const
510 return *
static_cast<pointer
>(p_value);
514 pointer operator &()
const
516 return static_cast<pointer
>(p_value);
519 pointer operator ->()
const
521 return static_cast<pointer
>(p_value);
526 return lhs.p_value ==
rhs.p_value;
554 : p_value(ETL_NULLPTR)
559 : p_value(
other.p_value)
564 : p_value(
other.p_value)
571 p_value = p_value->etl_next;
579 p_value = p_value->etl_next;
585 p_value =
other.p_value;
589 const_reference operator *()
const
591 return *
static_cast<const value_type*
>(p_value);
594 const_pointer operator &()
const
596 return static_cast<const value_type*
>(p_value);
599 const_pointer operator ->()
const
601 return static_cast<const value_type*
>(p_value);
606 return lhs.p_value ==
rhs.p_value;
621 const link_type* p_value;
624 typedef typename etl::iterator_traits<iterator>::difference_type difference_type;
643 template <
typename TIterator>
646 this->
assign(first, last);
653 template <
typename...
TLinks>
656 ETL_STATIC_ASSERT((etl::is_base_of_all<link_type, TLinks...>::value),
"Mixed link types");
659 this->
start.etl_next = &first;
734 return *
static_cast<pointer
>(this->
get_head());
742 return *
static_cast<const value_type*
>(this->
get_head());
759 template <
typename TIterator>
762 while (first != last)
797 if (first !=
end() && (first != last))
801 link_type*
p_first = first.p_value;
802 link_type*
p_last = last.p_value;
825 return static_cast<node_type*
>(this->
remove_link(
const_cast<node_type*
>(&
node)));
831 node_type*
erase(
const node_type* p_node)
833 return static_cast<node_type*
>(this->
remove_link(
const_cast<node_type*
>(p_node)));
840 template <
typename TIsEqual>
849 link_type* current = last->etl_next;
854 if (
isEqual(*
static_cast<pointer
>(current), *
static_cast<pointer
>(last)))
864 current = last->etl_next;
901 template <
typename TCompare>
1016 void remove(const_reference value)
1038 template <
typename TPredicate>
1068 link_type& first = *
other.get_head();
1075 link_type&
before = *position.p_value;
1076 link_type&
after = *position.p_value->etl_next;
1080 link_type* last = &
before;
1081 while (last->etl_next != &
other.terminator)
1083 last = last->etl_next;
1098 link_type&
before = *position.p_value;
1124 link_type* first =
begin_.p_value;
1125 link_type* last = first;
1127 while (last->etl_next !=
end_.p_value)
1129 last = last->etl_next;
1134 etl::unlink_after(*first, *last);
1137 link_type*
before = position.p_value;
1154 template <
typename TCompare>
1159#if ETL_IS_DEBUG_BUILD
1238 template <
typename...
TLinks>
1241 link_type* current = &first;
1243 ((current->etl_next = &
links, current = &
links, ++count), ...);
1247#elif ETL_USING_CPP11
1260 template <
typename...
TLinks>
1264 first.etl_next = &next;
1272 link_type* get_next(link_type* link)
const
1274 return link->etl_next;
const_iterator
Definition intrusive_forward_list.h:548
iterator.
Definition intrusive_forward_list.h:470
Definition intrusive_forward_list.h:140
bool contains_node(const link_type &search_link) const
Definition intrusive_forward_list.h:260
bool is_trivial_list() const
Is the intrusive_forward_list a trivial length?
Definition intrusive_forward_list.h:300
link_type start
The link pointer that acts as the intrusive_forward_list start.
Definition intrusive_forward_list.h:276
void reverse()
Reverses the intrusive_forward_list.
Definition intrusive_forward_list.h:218
void insert_link_after(link_type &position, link_type &link)
Insert a link.
Definition intrusive_forward_list.h:308
~intrusive_forward_list_base()
Destructor.
Definition intrusive_forward_list.h:292
bool empty() const
Returns true if the list has no elements.
Definition intrusive_forward_list.h:243
static link_type terminator
The link that acts as the intrusive_forward_list terminator.
Definition intrusive_forward_list.h:277
size_t current_size
Counts the number of elements in the list.
Definition intrusive_forward_list.h:279
intrusive_forward_list_base()
Constructor.
Definition intrusive_forward_list.h:284
link_type * remove_link(link_type *link)
Definition intrusive_forward_list.h:386
bool contains_node(const link_type *search_link) const
Definition intrusive_forward_list.h:269
void initialise()
Initialise the intrusive_forward_list.
Definition intrusive_forward_list.h:352
void pop_front()
Removes a value from the front of the intrusive_forward_list.
Definition intrusive_forward_list.h:207
link_type * is_link_in_list(const link_type *search_link) const
Definition intrusive_forward_list.h:362
link_type * get_head()
Get the head link.
Definition intrusive_forward_list.h:336
const link_type * get_head() const
Get the head link.
Definition intrusive_forward_list.h:344
void disconnect_link_after(link_type &link)
Remove a link.
Definition intrusive_forward_list.h:318
void assign(TIterator first, TIterator last)
Definition intrusive_forward_list.h:169
size_t size() const
Returns the number of elements.
Definition intrusive_forward_list.h:251
void push_front(link_type &value)
Pushes a value to the front of the intrusive_forward_list.
Definition intrusive_forward_list.h:197
void clear()
Clears the intrusive_forward_list.
Definition intrusive_forward_list.h:149
link_type * remove_link_range_after(link_type *p_first, link_type *p_last)
Remove a range of elements.
Definition intrusive_forward_list.h:410
Definition intrusive_forward_list.h:69
Definition intrusive_forward_list.h:55
Definition intrusive_forward_list.h:97
Definition intrusive_forward_list.h:83
Definition intrusive_forward_list.h:111
Definition intrusive_forward_list.h:125
Definition intrusive_forward_list.h:448
const_iterator before_begin() const
Gets before the beginning of the intrusive_forward_list.
Definition intrusive_forward_list.h:692
bool contains(const_reference value) const
Definition intrusive_forward_list.h:1215
iterator erase_after(iterator first, iterator last)
Erases a range of elements.
Definition intrusive_forward_list.h:795
void sort(TCompare compare)
Definition intrusive_forward_list.h:902
const_iterator cbegin() const
Gets the beginning of the intrusive_forward_list.
Definition intrusive_forward_list.h:700
void splice_after(iterator position, etl::intrusive_forward_list< TValue, TLink > &other)
Splice another list into this one.
Definition intrusive_forward_list.h:1061
~intrusive_forward_list()
Destructor.
Definition intrusive_forward_list.h:636
void unique(TIsEqual isEqual)
Definition intrusive_forward_list.h:841
void splice_after(iterator position, etl::intrusive_forward_list< TValue, TLink > &other, iterator begin_, iterator end_)
Splice a range of elements from another list into this one.
Definition intrusive_forward_list.h:1113
void splice_after(iterator position, etl::intrusive_forward_list< TValue, TLink > &other, iterator isource)
Splice an element from another list into this one.
Definition intrusive_forward_list.h:1096
void insert_after(iterator position, TIterator first, TIterator last)
Inserts a range of values to the intrusive_forward_list after the specified position.
Definition intrusive_forward_list.h:760
intrusive_forward_list(TIterator first, TIterator last, typename etl::enable_if<!etl::is_integral< TIterator >::value, int >::type=0)
Constructor from range.
Definition intrusive_forward_list.h:644
void remove_if(TPredicate predicate)
Removes according to a predicate.
Definition intrusive_forward_list.h:1039
iterator erase_after(iterator position)
Erases the value at the specified position.
Definition intrusive_forward_list.h:776
iterator insert_after(iterator position, value_type &value)
Inserts a value to the intrusive_forward_list after the specified position.
Definition intrusive_forward_list.h:748
const_iterator begin() const
Gets the beginning of the intrusive_forward_list.
Definition intrusive_forward_list.h:676
void merge(list_type &other, TCompare compare)
Merge another list into this one. Both lists should be sorted.
Definition intrusive_forward_list.h:1155
iterator end()
Gets the end of the intrusive_forward_list.
Definition intrusive_forward_list.h:708
iterator before_begin()
Gets before the beginning of the intrusive_forward_list.
Definition intrusive_forward_list.h:684
const_iterator end() const
Gets the end of the intrusive_forward_list.
Definition intrusive_forward_list.h:716
const_reference front() const
Gets a const reference to the first element.
Definition intrusive_forward_list.h:740
const_iterator cend() const
Gets the end of the intrusive_forward_list.
Definition intrusive_forward_list.h:724
void merge(list_type &other)
Merge another list into this one. Both lists should be sorted.
Definition intrusive_forward_list.h:1146
void sort()
Sort using in-place merge sort algorithm.
Definition intrusive_forward_list.h:871
intrusive_forward_list()
Constructor.
Definition intrusive_forward_list.h:629
iterator begin()
Gets the beginning of the intrusive_forward_list.
Definition intrusive_forward_list.h:668
node_type * erase(const node_type *p_node)
Erases the specified node.
Definition intrusive_forward_list.h:831
node_type * erase(const node_type &node)
Erases the specified node.
Definition intrusive_forward_list.h:823
reference front()
Gets a reference to the first element.
Definition intrusive_forward_list.h:732
ETL_CONSTEXPR14 bool operator==(const etl::expected< TValue, TError > &lhs, const etl::expected< TValue2, TError2 > &rhs)
Equivalence operators.
Definition expected.h:974
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
enable_if
Definition type_traits_generator.h:1230
is_integral
Definition type_traits_generator.h:1040
bitset_ext
Definition absolute.h:38
ETL_NODISCARD ETL_CONSTEXPR14 T round_half_even_unscaled(T value) ETL_NOEXCEPT
Definition scaled_rounding.h:314
iterator
Definition iterator.h:399
Definition functional.h:170