31#ifndef ETL_INTRUSIVE_LINKS_INCLUDED
32#define ETL_INTRUSIVE_LINKS_INCLUDED
96 : etl_next(ETL_NULLPTR)
108 : etl_next(
other.etl_next)
115 etl_next =
other.etl_next;
123 etl_next = ETL_NULLPTR;
128 bool is_linked()
const
130 return etl_next != ETL_NULLPTR;
135 bool has_next()
const
137 return etl_next != ETL_NULLPTR;
163 template <
typename TLink>
171 template <
typename TLink>
179 template <
typename TLink>
188 template <
typename TLink>
192 if (
lhs != ETL_NULLPTR)
200 template <
typename TLink>
209 template <
typename TLink>
213 if (
lhs != ETL_NULLPTR)
223 template <
typename TLink>
227 rhs.etl_next =
lhs.etl_next;
233 template <
typename TLink>
237 if (
lhs != ETL_NULLPTR)
239 if (
rhs != ETL_NULLPTR)
241 rhs->etl_next =
lhs->etl_next;
250 template <
typename TLink>
254 if (
rhs != ETL_NULLPTR)
256 rhs->etl_next =
lhs.etl_next;
264 template <
typename TLink>
268 if (
lhs != ETL_NULLPTR)
270 rhs.etl_next =
lhs->etl_next;
277 template <
typename TLink>
281 last.etl_next =
lhs.etl_next;
282 lhs.etl_next = &first;
287 template <
typename TLink>
291 if (
lhs != ETL_NULLPTR)
293 last.etl_next =
lhs->etl_next;
294 lhs->etl_next = &first;
298 last.etl_next = ETL_NULLPTR;
306 template <
typename TLink>
310 if (
node.etl_next != ETL_NULLPTR)
318 return node.etl_next;
323 template <
typename TLink>
331 before.etl_next = last.etl_next;
339 template <
typename TLink>
343 return node.is_linked();
347 template <
typename TLink>
351 return node->is_linked();
358 template <
typename TLink>
360 link_clear(
TLink& start)
362 start.etl_next = ETL_NULLPTR;
367 template <
typename TLink>
369 link_clear(
TLink* start)
371 if (start != ETL_NULLPTR)
373 etl::link_clear(*start);
381 template <
typename TLink>
383 link_clear_range(
TLink& start)
385 TLink* current = &start;
387 while (current != ETL_NULLPTR)
389 TLink* next = current->etl_next;
397 template <
typename TLink>
399 link_clear_range(
TLink* start)
401 if (start != ETL_NULLPTR)
403 etl::link_clear_range(*start);
415 TLink* current = &first;
416 ((current->etl_next = &
links, current = &
links), ...);
428 if (first != ETL_NULLPTR)
441 template <
typename TLink>
455 first.etl_next = &next;
462 template <
typename TLink>
466 if (first != ETL_NULLPTR)
483 if (first != ETL_NULLPTR)
495 template <
typename TLink>
497 detach_linked_list(
TLink& first)
499 link_clear_range(first);
503 template <
typename TLink>
505 detach_linked_list(
TLink* first)
507 if (first != ETL_NULLPTR)
509 detach_linked_list(*first);
516 template <
size_t ID_>
526 : etl_previous(ETL_NULLPTR)
527 , etl_next(ETL_NULLPTR)
540 : etl_previous(
other.etl_previous)
541 , etl_next(
other.etl_next)
548 etl_previous =
other.etl_previous;
549 etl_next =
other.etl_next;
557 etl_previous = ETL_NULLPTR;
558 etl_next = ETL_NULLPTR;
563 bool is_linked()
const
565 return (etl_previous != ETL_NULLPTR) || (etl_next != ETL_NULLPTR);
570 bool has_next()
const
572 return etl_next != ETL_NULLPTR;
577 bool has_previous()
const
579 return etl_previous != ETL_NULLPTR;
623 using ETL_OR_STD::swap;
624 swap(etl_previous, etl_next);
631 if (etl_previous != ETL_NULLPTR)
633 etl_previous->etl_next = etl_next;
637 if (etl_next != ETL_NULLPTR)
639 etl_next->etl_previous = etl_previous;
650 template <
typename TLink>
658 template <
typename TLink>
666 template <
typename TLink>
676 template <
typename TLink>
680 if (
lhs != ETL_NULLPTR)
685 if (
rhs != ETL_NULLPTR)
693 template <
typename TLink>
699 if (
rhs != ETL_NULLPTR)
707 template <
typename TLink>
711 if (
lhs != ETL_NULLPTR)
721 template <
typename TLink>
725 rhs.etl_next =
lhs.etl_next;
728 if (
lhs.etl_next != ETL_NULLPTR)
730 lhs.etl_next->etl_previous = &
rhs;
740 template <
typename TLink>
744 if (
rhs != ETL_NULLPTR)
746 if (
lhs != ETL_NULLPTR)
748 rhs->etl_next =
lhs->etl_next;
754 if (
lhs != ETL_NULLPTR)
756 if (
lhs->etl_next != ETL_NULLPTR)
758 lhs->etl_next->etl_previous =
rhs;
767 template <
typename TLink>
771 if (
rhs != ETL_NULLPTR)
773 rhs->etl_next =
lhs.etl_next;
777 if (
lhs.etl_next != ETL_NULLPTR)
779 lhs.etl_next->etl_previous =
rhs;
787 template <
typename TLink>
791 if (
lhs != ETL_NULLPTR)
793 rhs.etl_next =
lhs->etl_next;
798 if (
lhs != ETL_NULLPTR)
800 if (
lhs->etl_next != ETL_NULLPTR)
802 lhs->etl_next->etl_previous = &
rhs;
811 template <
typename TLink>
815 last.etl_next =
lhs.etl_next;
816 first.etl_previous = &
lhs;
818 if (last.etl_next != ETL_NULLPTR)
820 last.etl_next->etl_previous = &last;
823 lhs.etl_next = &first;
828 template <
typename TLink>
832 if (
lhs != ETL_NULLPTR)
834 last.etl_next =
lhs->etl_next;
838 last.etl_next = ETL_NULLPTR;
841 first.etl_previous =
lhs;
843 if (last.etl_next != ETL_NULLPTR)
845 last.etl_next->etl_previous = &last;
848 if (
lhs != ETL_NULLPTR)
850 lhs->etl_next = &first;
858 template <
typename TLink>
867 template <
typename TLink>
877 if (last.etl_next != ETL_NULLPTR)
879 last.etl_next->etl_previous = first.etl_previous;
882 if (first.etl_previous != ETL_NULLPTR)
884 first.etl_previous->etl_next = last.etl_next;
887 first.etl_previous = ETL_NULLPTR;
888 last.etl_next = ETL_NULLPTR;
895 template <
typename TLink>
899 return node.is_linked();
903 template <
typename TLink>
907 return node->is_linked();
914 template <
typename TLink>
916 link_clear_range(
TLink& start)
918 TLink* current = &start;
920 while (current != ETL_NULLPTR)
922 TLink* next = current->etl_next;
930 template <
typename TLink>
932 link_clear_range(
TLink* start)
934 etl::link_clear_range(*start);
945 TLink* current = &first;
946 ((current->etl_next = &
links,
static_cast<TLink&
>(
links).etl_previous = current, current = &
links), ...);
958 TLink* current = first;
959 ((current->etl_next =
links,
static_cast<TLink*
>(
links)->etl_previous = current, current =
links), ...);
967 template <
typename TLink>
981 first.etl_next = &next;
982 next.etl_previous = &first;
994 if (first != ETL_NULLPTR)
1006 template <
typename TLink>
1008 detach_linked_list(
TLink& first)
1010 link_clear_range(first);
1014 template <
typename TLink>
1016 detach_linked_list(
TLink* first)
1018 if (first != ETL_NULLPTR)
1020 detach_linked_list(*first);
1027 template <
size_t ID_>
1037 : etl_parent(ETL_NULLPTR)
1038 , etl_left(ETL_NULLPTR)
1039 , etl_right(ETL_NULLPTR)
1045 : etl_parent(p_parent)
1053 : etl_parent(
other.etl_parent)
1054 , etl_left(
other.etl_left)
1055 , etl_right(
other.etl_right)
1062 etl_parent =
other.etl_parent;
1063 etl_left =
other.etl_left;
1064 etl_right =
other.etl_right;
1072 etl_parent = ETL_NULLPTR;
1073 etl_left = ETL_NULLPTR;
1074 etl_right = ETL_NULLPTR;
1078 bool is_linked()
const
1080 return (etl_parent != ETL_NULLPTR) || (etl_left != ETL_NULLPTR) || (etl_right != ETL_NULLPTR);
1085 bool has_parent()
const
1087 return etl_parent != ETL_NULLPTR;
1092 bool has_left()
const
1094 return etl_left != ETL_NULLPTR;
1099 bool has_right()
const
1101 return etl_right != ETL_NULLPTR;
1164 using ETL_OR_STD::swap;
1165 swap(etl_left, etl_right);
1174 template <
typename TLink>
1182 template <
typename TLink>
1191 template <
typename TLink>
1195 parent.etl_left = &
leaf;
1196 leaf.etl_parent = &parent;
1201 template <
typename TLink>
1205 if (parent != ETL_NULLPTR)
1207 parent->etl_left =
leaf;
1210 if (
leaf != ETL_NULLPTR)
1212 leaf->etl_parent = parent;
1218 template <
typename TLink>
1222 parent.etl_left =
leaf;
1224 if (
leaf != ETL_NULLPTR)
1226 leaf->etl_parent = &parent;
1232 template <
typename TLink>
1236 if (parent != ETL_NULLPTR)
1238 parent->etl_left = &
leaf;
1241 leaf.etl_parent = parent;
1248 template <
typename TLink>
1252 parent.etl_right = &
leaf;
1253 leaf.etl_parent = &parent;
1257 template <
typename TLink>
1261 if (parent != ETL_NULLPTR)
1263 parent->etl_right =
leaf;
1266 if (
leaf != ETL_NULLPTR)
1268 leaf->etl_parent = parent;
1273 template <
typename TLink>
1277 parent.etl_right =
leaf;
1279 if (
leaf != ETL_NULLPTR)
1281 leaf->etl_parent = &parent;
1286 template <
typename TLink>
1290 if (parent != ETL_NULLPTR)
1292 parent->etl_right = &
leaf;
1295 leaf.etl_parent = parent;
1302 template <
typename TLink>
1306 parent.etl_right =
leaf.etl_left;
1308 if (parent.etl_right != ETL_NULLPTR)
1310 parent.etl_right->etl_parent = &parent;
1313 leaf.etl_parent = parent.etl_parent;
1314 parent.etl_parent = &
leaf;
1315 leaf.etl_left = &parent;
1320 template <
typename TLink>
1324 if ((parent != ETL_NULLPTR) && (
leaf != ETL_NULLPTR))
1326 link_rotate_left(*parent, *
leaf);
1332 template <
typename TLink>
1336 if (
leaf != ETL_NULLPTR)
1338 link_rotate_left(parent, *
leaf);
1344 template <
typename TLink>
1348 if (parent != ETL_NULLPTR)
1350 link_rotate_left(*parent,
leaf);
1357 template <
typename TLink>
1361 parent.etl_left =
leaf.etl_right;
1363 if (parent.etl_left != ETL_NULLPTR)
1365 parent.etl_left->etl_parent = &parent;
1368 leaf.etl_parent = parent.etl_parent;
1369 parent.etl_parent = &
leaf;
1370 leaf.etl_right = &parent;
1374 template <
typename TLink>
1378 if ((parent != ETL_NULLPTR) && (
leaf != ETL_NULLPTR))
1380 link_rotate_right(*parent, *
leaf);
1384 template <
typename TLink>
1388 if (
leaf != ETL_NULLPTR)
1390 link_rotate_right(parent, *
leaf);
1395 template <
typename TLink>
1399 if (parent != ETL_NULLPTR)
1401 link_rotate_right(*parent,
leaf);
1410 template <
typename TLink>
1414 if (parent.etl_left == &
leaf)
1416 etl::link_rotate_right(parent,
leaf);
1420 etl::link_rotate_left(parent,
leaf);
1427 template <
typename TLink>
1431 if ((parent != ETL_NULLPTR) && (
leaf != ETL_NULLPTR))
1433 if (parent->etl_left ==
leaf)
1435 etl::link_rotate_right(*parent, *
leaf);
1439 etl::link_rotate_left(*parent, *
leaf);
1447 template <
typename TLink>
1451 if (
leaf != ETL_NULLPTR)
1453 if (parent.etl_left ==
leaf)
1455 etl::link_rotate_right(parent, *
leaf);
1459 etl::link_rotate_left(parent, *
leaf);
1467 template <
typename TLink>
1471 if (parent != ETL_NULLPTR)
1473 if (parent->etl_left == &
leaf)
1475 etl::link_rotate_right(*parent,
leaf);
1479 etl::link_rotate_left(*parent,
leaf);
1485 template <
typename TLink>
1493 template <
typename TLink>
1501 template <
typename TLink>
1505 return node.is_linked();
1509 template <
typename TLink>
1513 return node->is_linked();
Link exception.
Definition intrusive_links.h:61
not unlinked exception.
Definition intrusive_links.h:74
Definition exception.h:47
enable_if
Definition type_traits_generator.h:1230
is_same
Definition type_traits_generator.h:1080
bitset_ext
Definition absolute.h:38
etl::enable_if< etl::is_same< TLink, etl::tree_link< TLink::ID > >::value, void >::type link_rotate(TLink &parent, TLink &leaf)
Automatically detects whether a left or right rotate is expected.
Definition intrusive_links.h:1412
void swap(etl::array< T, SIZE > &lhs, etl::array< T, SIZE > &rhs)
Template deduction guides.
Definition array.h:1085
ETL_NODISCARD ETL_CONSTEXPR14 T round_half_even_unscaled(T value) ETL_NOEXCEPT
Definition scaled_rounding.h:314
A bidirectional link.
Definition intrusive_links.h:518
A forward link.
Definition intrusive_links.h:88
Definition intrusive_links.h:652
Definition intrusive_links.h:165
Definition intrusive_links.h:1176
A binary tree link.
Definition intrusive_links.h:1029