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;
225 link_type* current =
start.etl_next;
226 link_type* next =
start.etl_next;
230 next = next->etl_next;
231 current->etl_next = previous;
301 return (
size() <= 1U);
319 link_type* p_next = link.etl_next;
321 if (p_next != &this->terminator)
337 return start.etl_next;
345 return start.etl_next;
366 while (
p_link != ETL_NULLPTR)
387 link_type* result = ETL_NULLPTR;
393 link_type* p_next = link->etl_next;
397 if (p_next != &this->terminator)
421 link_type* p_next =
p_unlink->etl_next;
426 if (
p_after == &this->terminator)
437 template <
typename TLink>
445 template <
typename TValue,
typename TLink>
451 typedef typename etl::intrusive_forward_list_base<TLink>::link_type link_type;
454 typedef TValue value_type;
455 typedef value_type* pointer;
456 typedef const value_type* const_pointer;
457 typedef value_type& reference;
458 typedef const value_type& const_reference;
459 typedef size_t size_type;
476 : p_value(ETL_NULLPTR)
481 : p_value(
other.p_value)
488 p_value = p_value->etl_next;
496 p_value = p_value->etl_next;
502 p_value =
other.p_value;
506 reference operator *()
const
509 return *
static_cast<pointer
>(p_value);
513 pointer operator &()
const
515 return static_cast<pointer
>(p_value);
518 pointer operator ->()
const
520 return static_cast<pointer
>(p_value);
525 return lhs.p_value ==
rhs.p_value;
553 : p_value(ETL_NULLPTR)
558 : p_value(
other.p_value)
563 : p_value(
other.p_value)
570 p_value = p_value->etl_next;
578 p_value = p_value->etl_next;
584 p_value =
other.p_value;
588 const_reference operator *()
const
590 return *
static_cast<const value_type*
>(p_value);
593 const_pointer operator &()
const
595 return static_cast<const value_type*
>(p_value);
598 const_pointer operator ->()
const
600 return static_cast<const value_type*
>(p_value);
605 return lhs.p_value ==
rhs.p_value;
620 const link_type* p_value;
623 typedef typename etl::iterator_traits<iterator>::difference_type difference_type;
642 template <
typename TIterator>
645 this->
assign(first, last);
652 template <
typename...
TLinks>
655 ETL_STATIC_ASSERT((etl::is_base_of_all<link_type, TLinks...>::value),
"Mixed link types");
658 this->
start.etl_next = &first;
733 return *
static_cast<pointer
>(this->
get_head());
741 return *
static_cast<const value_type*
>(this->
get_head());
758 template <
typename TIterator>
761 while (first != last)
796 if (first !=
end() && (first != last))
800 link_type*
p_first = first.p_value;
801 link_type*
p_last = last.p_value;
824 return static_cast<node_type*
>(this->
remove_link(
const_cast<node_type*
>(&
node)));
830 node_type*
erase(
const node_type* p_node)
832 return static_cast<node_type*
>(this->
remove_link(
const_cast<node_type*
>(p_node)));
839 template <
typename TIsEqual>
848 link_type* current = last->etl_next;
853 if (
isEqual(*
static_cast<pointer
>(current), *
static_cast<pointer
>(last)))
863 current = last->etl_next;
900 template <
typename TCompare>
1015 void remove(const_reference value)
1037 template <
typename TPredicate>
1067 link_type& first = *
other.get_head();
1074 link_type&
before = *position.p_value;
1075 link_type&
after = *position.p_value->etl_next;
1079 link_type* last = &
before;
1080 while (last->etl_next != &
other.terminator)
1082 last = last->etl_next;
1097 link_type&
before = *position.p_value;
1123 link_type* first =
begin_.p_value;
1124 link_type* last = first;
1126 while (last->etl_next !=
end_.p_value)
1128 last = last->etl_next;
1133 etl::unlink_after(*first, *last);
1136 link_type*
before = position.p_value;
1153 template <
typename TCompare>
1158#if ETL_IS_DEBUG_BUILD
1237 template <
typename...
TLinks>
1240 link_type* current = &first;
1242 ((current->etl_next = &
links, current = &
links, ++count), ...);
1246#elif ETL_USING_CPP11
1259 template <
typename...
TLinks>
1263 first.etl_next = &next;
1271 link_type* get_next(link_type* link)
const
1273 return link->etl_next;
const_iterator
Definition intrusive_forward_list.h:547
iterator.
Definition intrusive_forward_list.h:469
Definition intrusive_forward_list.h:140
bool contains_node(const link_type &search_link) const
Definition intrusive_forward_list.h:259
bool is_trivial_list() const
Is the intrusive_forward_list a trivial length?
Definition intrusive_forward_list.h:299
link_type start
The link pointer that acts as the intrusive_forward_list start.
Definition intrusive_forward_list.h:275
void reverse()
Reverses the intrusive_forward_list.
Definition intrusive_forward_list.h:217
void insert_link_after(link_type &position, link_type &link)
Insert a link.
Definition intrusive_forward_list.h:307
~intrusive_forward_list_base()
Destructor.
Definition intrusive_forward_list.h:291
bool empty() const
Returns true if the list has no elements.
Definition intrusive_forward_list.h:242
static link_type terminator
The link that acts as the intrusive_forward_list terminator.
Definition intrusive_forward_list.h:276
size_t current_size
Counts the number of elements in the list.
Definition intrusive_forward_list.h:278
intrusive_forward_list_base()
Constructor.
Definition intrusive_forward_list.h:283
link_type * remove_link(link_type *link)
Definition intrusive_forward_list.h:385
bool contains_node(const link_type *search_link) const
Definition intrusive_forward_list.h:268
void initialise()
Initialise the intrusive_forward_list.
Definition intrusive_forward_list.h:351
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:361
link_type * get_head()
Get the head link.
Definition intrusive_forward_list.h:335
const link_type * get_head() const
Get the head link.
Definition intrusive_forward_list.h:343
void disconnect_link_after(link_type &link)
Remove a link.
Definition intrusive_forward_list.h:317
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:250
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:409
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:447
const_iterator before_begin() const
Gets before the beginning of the intrusive_forward_list.
Definition intrusive_forward_list.h:691
bool contains(const_reference value) const
Definition intrusive_forward_list.h:1214
iterator erase_after(iterator first, iterator last)
Erases a range of elements.
Definition intrusive_forward_list.h:794
void sort(TCompare compare)
Definition intrusive_forward_list.h:901
const_iterator cbegin() const
Gets the beginning of the intrusive_forward_list.
Definition intrusive_forward_list.h:699
void splice_after(iterator position, etl::intrusive_forward_list< TValue, TLink > &other)
Splice another list into this one.
Definition intrusive_forward_list.h:1060
~intrusive_forward_list()
Destructor.
Definition intrusive_forward_list.h:635
void unique(TIsEqual isEqual)
Definition intrusive_forward_list.h:840
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:1112
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:1095
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:759
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:643
void remove_if(TPredicate predicate)
Removes according to a predicate.
Definition intrusive_forward_list.h:1038
iterator erase_after(iterator position)
Erases the value at the specified position.
Definition intrusive_forward_list.h:775
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:747
const_iterator begin() const
Gets the beginning of the intrusive_forward_list.
Definition intrusive_forward_list.h:675
void merge(list_type &other, TCompare compare)
Merge another list into this one. Both lists should be sorted.
Definition intrusive_forward_list.h:1154
iterator end()
Gets the end of the intrusive_forward_list.
Definition intrusive_forward_list.h:707
iterator before_begin()
Gets before the beginning of the intrusive_forward_list.
Definition intrusive_forward_list.h:683
const_iterator end() const
Gets the end of the intrusive_forward_list.
Definition intrusive_forward_list.h:715
const_reference front() const
Gets a const reference to the first element.
Definition intrusive_forward_list.h:739
const_iterator cend() const
Gets the end of the intrusive_forward_list.
Definition intrusive_forward_list.h:723
void merge(list_type &other)
Merge another list into this one. Both lists should be sorted.
Definition intrusive_forward_list.h:1145
void sort()
Sort using in-place merge sort algorithm.
Definition intrusive_forward_list.h:870
intrusive_forward_list()
Constructor.
Definition intrusive_forward_list.h:628
iterator begin()
Gets the beginning of the intrusive_forward_list.
Definition intrusive_forward_list.h:667
node_type * erase(const node_type *p_node)
Erases the specified node.
Definition intrusive_forward_list.h:830
node_type * erase(const node_type &node)
Erases the specified node.
Definition intrusive_forward_list.h:822
reference front()
Gets a reference to the first element.
Definition intrusive_forward_list.h:731
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
enable_if
Definition type_traits_generator.h:1254
is_integral
Definition type_traits_generator.h:1064
bitset_ext
Definition absolute.h:39
ETL_NODISCARD ETL_CONSTEXPR14 T round_half_even_unscaled(T value) ETL_NOEXCEPT
Definition scaled_rounding.h:315
iterator
Definition iterator.h:399
Definition functional.h:170