inc/ecu/ntnode.h Source File

ECU: inc/ecu/ntnode.h Source File
ECU
ntnode.h
Go to the documentation of this file.
1 
14 #ifndef ECU_NTNODE_H_
15 #define ECU_NTNODE_H_
16 
17 /*------------------------------------------------------------*/
18 /*------------------------- INCLUDES -------------------------*/
19 /*------------------------------------------------------------*/
20 
21 /* STDLib. */
22 #include <stdbool.h>
23 #include <stddef.h>
24 #include <stdint.h>
25 
26 /* ECU. */
27 #include "ecu/dlist.h"
28 #include "ecu/object_id.h"
29 #include "ecu/utils.h"
30 
31 /*------------------------------------------------------------*/
32 /*---------------------- DEFINES AND MACROS ------------------*/
33 /*------------------------------------------------------------*/
34 
39 #define ECU_NTNODE_OBJ_UNUSED \
40  ((void *)0)
41 
46 #define ECU_NTNODE_DESTROY_UNUSED \
47  ((void (*)(struct ecu_ntnode *, ecu_object_id_t))0)
48 
62 #define ECU_NTNODE_GET_ENTRY(ptr_, type_, member_) \
63  ECU_CONTAINER_OF(ptr_, type_, member_)
64 
80 #define ECU_NTNODE_GET_CONST_ENTRY(ptr_, type_, member_) \
81  ECU_CONST_CONTAINER_OF(ptr_, type_, member_)
82 
95 #define ECU_NTNODE_CHILD_FOR_EACH(var_, iter_, parent_) \
96  for (struct ecu_ntnode *var_ = ecu_ntnode_child_iterator_begin(iter_, parent_); \
97  var_ != ecu_ntnode_child_iterator_end(iter_); \
98  var_ = ecu_ntnode_child_iterator_next(iter_))
99 
113 #define ECU_NTNODE_CONST_CHILD_FOR_EACH(var_, citer_, parent_) \
114  for (const struct ecu_ntnode *var_ = ecu_ntnode_child_iterator_cbegin(citer_, parent_); \
115  var_ != ecu_ntnode_child_iterator_cend(citer_); \
116  var_ = ecu_ntnode_child_iterator_cnext(citer_))
117 
132 #define ECU_NTNODE_NEXT_SIBLING_AT_FOR_EACH(var_, iter_, start_) \
133  for (struct ecu_ntnode *var_ = ecu_ntnode_next_sibling_iterator_at(iter_, start_); \
134  var_ != ecu_ntnode_next_sibling_iterator_end(iter_); \
135  var_ = ecu_ntnode_next_sibling_iterator_next(iter_))
136 
151 #define ECU_NTNODE_CONST_NEXT_SIBLING_AT_FOR_EACH(var_, citer_, start_) \
152  for (const struct ecu_ntnode *var_ = ecu_ntnode_next_sibling_iterator_cat(citer_, start_); \
153  var_ != ecu_ntnode_next_sibling_iterator_cend(citer_); \
154  var_ = ecu_ntnode_next_sibling_iterator_cnext(citer_))
155 
168 #define ECU_NTNODE_NEXT_SIBLING_FOR_EACH(var_, iter_, start_) \
169  for (struct ecu_ntnode *var_ = ecu_ntnode_next_sibling_iterator_begin(iter_, start_); \
170  var_ != ecu_ntnode_next_sibling_iterator_end(iter_); \
171  var_ = ecu_ntnode_next_sibling_iterator_next(iter_))
172 
185 #define ECU_NTNODE_CONST_NEXT_SIBLING_FOR_EACH(var_, citer_, start_) \
186  for (const struct ecu_ntnode *var_ = ecu_ntnode_next_sibling_iterator_cbegin(citer_, start_); \
187  var_ != ecu_ntnode_next_sibling_iterator_cend(citer_); \
188  var_ = ecu_ntnode_next_sibling_iterator_cnext(citer_))
189 
203 #define ECU_NTNODE_PARENT_AT_FOR_EACH(var_, iter_, start_) \
204  for (struct ecu_ntnode *var_ = ecu_ntnode_parent_iterator_at(iter_, start_); \
205  var_ != ecu_ntnode_parent_iterator_end(iter_); \
206  var_ = ecu_ntnode_parent_iterator_next(iter_))
207 
222 #define ECU_NTNODE_CONST_PARENT_AT_FOR_EACH(var_, citer_, start_) \
223  for (const struct ecu_ntnode *var_ = ecu_ntnode_parent_iterator_cat(citer_, start_); \
224  var_ != ecu_ntnode_parent_iterator_cend(citer_); \
225  var_ = ecu_ntnode_parent_iterator_cnext(citer_))
226 
239 #define ECU_NTNODE_PARENT_FOR_EACH(var_, iter_, start_) \
240  for (struct ecu_ntnode *var_ = ecu_ntnode_parent_iterator_begin(iter_, start_); \
241  var_ != ecu_ntnode_parent_iterator_end(iter_); \
242  var_ = ecu_ntnode_parent_iterator_next(iter_))
243 
256 #define ECU_NTNODE_CONST_PARENT_FOR_EACH(var_, citer_, start_) \
257  for (const struct ecu_ntnode *var_ = ecu_ntnode_parent_iterator_cbegin(citer_, start_); \
258  var_ != ecu_ntnode_parent_iterator_cend(citer_); \
259  var_ = ecu_ntnode_parent_iterator_cnext(citer_))
260 
275 #define ECU_NTNODE_POSTORDER_FOR_EACH(var_, iter_, root_) \
276  for (struct ecu_ntnode *var_ = ecu_ntnode_postorder_iterator_begin(iter_, root_); \
277  var_ != ecu_ntnode_postorder_iterator_end(iter_); \
278  var_ = ecu_ntnode_postorder_iterator_next(iter_))
279 
295 #define ECU_NTNODE_CONST_POSTORDER_FOR_EACH(var_, citer_, root_) \
296  for (const struct ecu_ntnode *var_ = ecu_ntnode_postorder_iterator_cbegin(citer_, root_); \
297  var_ != ecu_ntnode_postorder_iterator_cend(citer_); \
298  var_ = ecu_ntnode_postorder_iterator_cnext(citer_))
299 
315 #define ECU_NTNODE_PREORDER_FOR_EACH(var_, iter_, root_) \
316  for (struct ecu_ntnode *var_ = ecu_ntnode_preorder_iterator_begin(iter_, root_); \
317  var_ != ecu_ntnode_preorder_iterator_end(iter_); \
318  var_ = ecu_ntnode_preorder_iterator_next(iter_))
319 
335 #define ECU_NTNODE_CONST_PREORDER_FOR_EACH(var_, citer_, root_) \
336  for (const struct ecu_ntnode *var_ = ecu_ntnode_preorder_iterator_cbegin(citer_, root_); \
337  var_ != ecu_ntnode_preorder_iterator_cend(citer_); \
338  var_ = ecu_ntnode_preorder_iterator_cnext(citer_))
339 
354 #define ECU_NTNODE_PREV_SIBLING_AT_FOR_EACH(var_, iter_, start_) \
355  for (struct ecu_ntnode *var_ = ecu_ntnode_prev_sibling_iterator_at(iter_, start_); \
356  var_ != ecu_ntnode_prev_sibling_iterator_end(iter_); \
357  var_ = ecu_ntnode_prev_sibling_iterator_next(iter_))
358 
373 #define ECU_NTNODE_CONST_PREV_SIBLING_AT_FOR_EACH(var_, citer_, start_) \
374  for (const struct ecu_ntnode *var_ = ecu_ntnode_prev_sibling_iterator_cat(citer_, start_); \
375  var_ != ecu_ntnode_prev_sibling_iterator_cend(citer_); \
376  var_ = ecu_ntnode_prev_sibling_iterator_cnext(citer_))
377 
390 #define ECU_NTNODE_PREV_SIBLING_FOR_EACH(var_, iter_, start_) \
391  for (struct ecu_ntnode *var_ = ecu_ntnode_prev_sibling_iterator_begin(iter_, start_); \
392  var_ != ecu_ntnode_prev_sibling_iterator_end(iter_); \
393  var_ = ecu_ntnode_prev_sibling_iterator_next(iter_))
394 
407 #define ECU_NTNODE_CONST_PREV_SIBLING_FOR_EACH(var_, citer_, start_) \
408  for (const struct ecu_ntnode *var_ = ecu_ntnode_prev_sibling_iterator_cbegin(citer_, start_); \
409  var_ != ecu_ntnode_prev_sibling_iterator_cend(citer_); \
410  var_ = ecu_ntnode_prev_sibling_iterator_cnext(citer_))
411 
431 #define ECU_NTNODE_SIBLING_FOR_EACH(var_, iter_, start_) \
432  for (struct ecu_ntnode *var_ = ecu_ntnode_sibling_iterator_begin(iter_, start_); \
433  var_ != ecu_ntnode_sibling_iterator_end(iter_); \
434  var_ = ecu_ntnode_sibling_iterator_next(iter_))
435 
455 #define ECU_NTNODE_CONST_SIBLING_FOR_EACH(var_, citer_, start_) \
456  for (const struct ecu_ntnode *var_ = ecu_ntnode_sibling_iterator_cbegin(citer_, start_); \
457  var_ != ecu_ntnode_sibling_iterator_cend(citer_); \
458  var_ = ecu_ntnode_sibling_iterator_cnext(citer_))
459 
460 /*------------------------------------------------------------*/
461 /*--------------------------- NTNODE -------------------------*/
462 /*------------------------------------------------------------*/
463 
475 {
477  struct ecu_dnode dnode;
478 
480  struct ecu_dlist children;
481 
484 
488  void (*destroy)(struct ecu_ntnode *me, ecu_object_id_t id);
489 };
490 
491 /*------------------------------------------------------------*/
492 /*--------------------- NTNODE CHILD ITERATOR ----------------*/
493 /*------------------------------------------------------------*/
494 
502 {
505 
508  struct ecu_ntnode *next;
509 };
510 
518 {
520  const struct ecu_ntnode *current;
521 
524  const struct ecu_ntnode *next;
525 };
526 
527 /*------------------------------------------------------------*/
528 /*-------------------- NTNODE PARENT ITERATOR ----------------*/
529 /*------------------------------------------------------------*/
530 
538 {
541 
544  struct ecu_ntnode *next;
545 };
546 
554 {
556  const struct ecu_ntnode *current;
557 
560  const struct ecu_ntnode *next;
561 };
562 
563 /*------------------------------------------------------------*/
564 /*--------------- NTNODE NEXT SIBLING ITERATOR ---------------*/
565 /*------------------------------------------------------------*/
566 
574 {
577 
580  struct ecu_ntnode *next;
581 };
582 
590 {
592  const struct ecu_ntnode *current;
593 
596  const struct ecu_ntnode *next;
597 };
598 
599 /*------------------------------------------------------------*/
600 /*------------------- NTNODE POSTORDER ITERATOR --------------*/
601 /*------------------------------------------------------------*/
602 
610 {
613  struct ecu_ntnode delimiter;
614 
617  struct ecu_ntnode *root;
618 
621 
624  struct ecu_ntnode *next;
625 };
626 
634 {
637  struct ecu_ntnode delimiter;
638 
641  const struct ecu_ntnode *root;
642 
644  const struct ecu_ntnode *current;
645 
648  const struct ecu_ntnode *next;
649 };
650 
651 /*------------------------------------------------------------*/
652 /*------------------- NTNODE PREORDER ITERATOR ---------------*/
653 /*------------------------------------------------------------*/
654 
662 {
665  struct ecu_ntnode delimiter;
666 
669  struct ecu_ntnode *root;
670 
673 };
674 
682 {
685  struct ecu_ntnode delimiter;
686 
689  const struct ecu_ntnode *root;
690 
692  const struct ecu_ntnode *current;
693 };
694 
695 /*------------------------------------------------------------*/
696 /*--------------- NTNODE PREV SIBLING ITERATOR ---------------*/
697 /*------------------------------------------------------------*/
698 
706 {
709 
712  struct ecu_ntnode *next;
713 };
714 
722 {
724  const struct ecu_ntnode *current;
725 
728  const struct ecu_ntnode *next;
729 };
730 
731 /*------------------------------------------------------------*/
732 /*-------------------- NTNODE SIBLING ITERATOR ---------------*/
733 /*------------------------------------------------------------*/
734 
742 {
746  struct ecu_ntnode *end;
747 
750 
753  struct ecu_ntnode *next;
754 };
755 
763 {
767  const struct ecu_ntnode *end;
768 
770  const struct ecu_ntnode *current;
771 
774  const struct ecu_ntnode *next;
775 };
776 
777 /*------------------------------------------------------------*/
778 /*------------------ NTNODE MEMBER FUNCTIONS -----------------*/
779 /*------------------------------------------------------------*/
780 
781 #ifdef __cplusplus
782 extern "C" {
783 #endif
784 
807 extern void ecu_ntnode_ctor(struct ecu_ntnode *me,
808  void (*destroy)(struct ecu_ntnode *me, ecu_object_id_t id),
809  ecu_object_id_t id);
810 
827 extern void ecu_ntnode_destroy(struct ecu_ntnode *me);
842 extern void ecu_ntnode_clear(struct ecu_ntnode *me);
843 
852 extern size_t ecu_ntnode_count(const struct ecu_ntnode *me);
853 
861 extern struct ecu_ntnode *ecu_ntnode_first_child(struct ecu_ntnode *me);
862 
871 extern const struct ecu_ntnode *ecu_ntnode_first_cchild(const struct ecu_ntnode *me);
872 
880 extern ecu_object_id_t ecu_ntnode_id(const struct ecu_ntnode *me);
881 
889 extern bool ecu_ntnode_in_tree(const struct ecu_ntnode *me);
890 
902 extern void ecu_ntnode_insert_sibling_after(struct ecu_ntnode *pos, struct ecu_ntnode *sibling);
903 
915 extern void ecu_ntnode_insert_sibling_before(struct ecu_ntnode *pos, struct ecu_ntnode *sibling);
916 
924 extern bool ecu_ntnode_is_descendant(const struct ecu_ntnode *me);
925 
934 extern bool ecu_ntnode_is_leaf(const struct ecu_ntnode *me);
935 
944 extern bool ecu_ntnode_is_root(const struct ecu_ntnode *me);
945 
953 extern struct ecu_ntnode *ecu_ntnode_last_child(struct ecu_ntnode *me);
954 
963 extern const struct ecu_ntnode *ecu_ntnode_last_cchild(const struct ecu_ntnode *me);
964 
974 extern struct ecu_ntnode *ecu_ntnode_lca(struct ecu_ntnode *n1, struct ecu_ntnode *n2);
975 
986 extern const struct ecu_ntnode *ecu_ntnode_clca(const struct ecu_ntnode *n1, const struct ecu_ntnode *n2);
987 
995 extern size_t ecu_ntnode_level(const struct ecu_ntnode *me);
996 
1004 extern struct ecu_ntnode *ecu_ntnode_next(struct ecu_ntnode *me);
1005 
1014 extern const struct ecu_ntnode *ecu_ntnode_cnext(const struct ecu_ntnode *me);
1015 
1023 extern struct ecu_ntnode *ecu_ntnode_parent(struct ecu_ntnode *me);
1024 
1033 extern const struct ecu_ntnode *ecu_ntnode_cparent(const struct ecu_ntnode *me);
1034 
1042 extern struct ecu_ntnode *ecu_ntnode_prev(struct ecu_ntnode *me);
1043 
1052 extern const struct ecu_ntnode *ecu_ntnode_cprev(const struct ecu_ntnode *me);
1053 
1063 extern void ecu_ntnode_push_child_back(struct ecu_ntnode *parent, struct ecu_ntnode *child);
1064 
1074 extern void ecu_ntnode_push_child_front(struct ecu_ntnode *parent, struct ecu_ntnode *child);
1075 
1084 extern void ecu_ntnode_remove(struct ecu_ntnode *me);
1085 
1093 extern size_t ecu_ntnode_size(const struct ecu_ntnode *me);
1094 
1101 extern bool ecu_ntnode_valid(const struct ecu_ntnode *me);
1104 /*------------------------------------------------------------*/
1105 /*------------------------ CHILD ITERATOR --------------------*/
1106 /*------------------------------------------------------------*/
1107 
1127  struct ecu_ntnode *parent);
1128 
1139 
1150 
1167  const struct ecu_ntnode *parent);
1168 
1180 
1194 /*------------------------------------------------------------*/
1195 /*------------------- NEXT SIBLING ITERATOR ------------------*/
1196 /*------------------------------------------------------------*/
1197 
1215  struct ecu_ntnode *start);
1216 
1232  struct ecu_ntnode *start);
1233 
1244 
1255 
1270  const struct ecu_ntnode *start);
1271 
1288  const struct ecu_ntnode *start);
1289 
1301 
1315 /*------------------------------------------------------------*/
1316 /*------------------------ PARENT ITERATOR -------------------*/
1317 /*------------------------------------------------------------*/
1318 
1336  struct ecu_ntnode *start);
1337 
1352  struct ecu_ntnode *start);
1353 
1364 
1375 
1390  const struct ecu_ntnode *start);
1391 
1407  const struct ecu_ntnode *start);
1408 
1420 
1434 /*------------------------------------------------------------*/
1435 /*--------------------- POSTORDER ITERATOR -------------------*/
1436 /*------------------------------------------------------------*/
1437 
1456  struct ecu_ntnode *root);
1457 
1471 
1482 
1498  const struct ecu_ntnode *root);
1499 
1514 
1528 /*------------------------------------------------------------*/
1529 /*----------------------- PREORDER ITERATOR ------------------*/
1530 /*------------------------------------------------------------*/
1531 
1551  struct ecu_ntnode *root);
1552 
1566 
1577 
1594  const struct ecu_ntnode *root);
1595 
1610 
1624 /*------------------------------------------------------------*/
1625 /*------------------- PREV SIBLING ITERATOR ------------------*/
1626 /*------------------------------------------------------------*/
1627 
1645  struct ecu_ntnode *start);
1646 
1662  struct ecu_ntnode *start);
1663 
1674 
1685 
1700  const struct ecu_ntnode *start);
1701 
1718  const struct ecu_ntnode *start);
1719 
1731 
1745 /*------------------------------------------------------------*/
1746 /*----------------------- SIBLING ITERATOR -------------------*/
1747 /*------------------------------------------------------------*/
1748 
1766  struct ecu_ntnode *start);
1767 
1778 
1789 
1804  const struct ecu_ntnode *start);
1805 
1817 
1831 #ifdef __cplusplus
1832 }
1833 #endif
1834 
1835 #endif /* ECU_NTNODE_H_ */
const struct ecu_ntnode * ecu_ntnode_parent_iterator_cbegin(struct ecu_ntnode_parent_citerator *me, const struct ecu_ntnode *start)
Const-qualified version of ecu_ntnode_parent_iterator_begin(). Starts an iteration over all parents,...
const struct ecu_ntnode * ecu_ntnode_sibling_iterator_cend(struct ecu_ntnode_sibling_citerator *me)
Const-qualified version of ecu_ntnode_sibling_iterator_end(). Returns the ending node in the iteratio...
struct ecu_ntnode * ecu_ntnode_parent_iterator_next(struct ecu_ntnode_parent_iterator *me)
Returns the next parent in the iteration.
struct ecu_ntnode * ecu_ntnode_child_iterator_next(struct ecu_ntnode_child_iterator *me)
Returns the next child in the iteration.
const struct ecu_ntnode * ecu_ntnode_child_iterator_cnext(struct ecu_ntnode_child_citerator *me)
Const-qualified version of ecu_ntnode_child_iterator_next(). Returns the next child in the iteration.
struct ecu_ntnode * ecu_ntnode_next(struct ecu_ntnode *me)
Returns the node's next (right) sibling. NULL is returned if the node is the last (rightmost) sibling...
bool ecu_ntnode_is_leaf(const struct ecu_ntnode *me)
Returns true if the node is a leaf, meaning it has no children. False otherwise. Note that this retur...
void ecu_ntnode_ctor(struct ecu_ntnode *me, void(*destroy)(struct ecu_ntnode *me, ecu_object_id_t id), ecu_object_id_t id)
Node constructor.
bool ecu_ntnode_is_root(const struct ecu_ntnode *me)
Returns true if the node is a root, meaning it has no parent. False otherwise. Note that this returns...
struct ecu_ntnode * ecu_ntnode_sibling_iterator_begin(struct ecu_ntnode_sibling_iterator *me, struct ecu_ntnode *start)
Starts an iteration over all siblings, excluding the supplied starting node.
bool ecu_ntnode_in_tree(const struct ecu_ntnode *me)
Returns true if the node is in a tree. False otherwise. Note that this returns true for a root node t...
const struct ecu_ntnode * ecu_ntnode_prev_sibling_iterator_cnext(struct ecu_ntnode_prev_sibling_citerator *me)
Const-qualified version of ecu_ntnode_prev_sibling_iterator_next(). Returns the next node in the iter...
struct ecu_ntnode * ecu_ntnode_postorder_iterator_end(struct ecu_ntnode_postorder_iterator *me)
Returns the ending node in the iteration, which is a dummy delimiter.
const struct ecu_ntnode * ecu_ntnode_prev_sibling_iterator_cbegin(struct ecu_ntnode_prev_sibling_citerator *me, const struct ecu_ntnode *start)
Const-qualified version of ecu_ntnode_prev_sibling_iterator_begin(). Starts an iteration over all pre...
struct ecu_ntnode * ecu_ntnode_first_child(struct ecu_ntnode *me)
Returns the node's first (leftmost) child. NULL is returned if the node has no children.
const struct ecu_ntnode * ecu_ntnode_clca(const struct ecu_ntnode *n1, const struct ecu_ntnode *n2)
Const-qualified version of ecu_ntnode_lca(). Returns the least common ancestor of n1 and n2....
struct ecu_ntnode * ecu_ntnode_parent(struct ecu_ntnode *me)
Returns the supplied node's parent. NULL is returned if the node is a root.
const struct ecu_ntnode * ecu_ntnode_cparent(const struct ecu_ntnode *me)
Const-qualified version of ecu_ntnode_parent(). Returns the supplied node's parent....
bool ecu_ntnode_is_descendant(const struct ecu_ntnode *me)
Returns true if the node is in a tree and is not the root. False otherwise.
size_t ecu_ntnode_size(const struct ecu_ntnode *me)
Returns the total number of descendants (children, grandchildren, etc) the node has....
ecu_object_id_t ecu_ntnode_id(const struct ecu_ntnode *me)
Returns the node's ID assigned when it was constructed in ecu_ntnode_ctor().
struct ecu_ntnode * ecu_ntnode_parent_iterator_end(struct ecu_ntnode_parent_iterator *me)
Returns the ending node in the iteration, which is NULL.
struct ecu_ntnode * ecu_ntnode_lca(struct ecu_ntnode *n1, struct ecu_ntnode *n2)
Returns the least common ancestor of n1 and n2. Returns NULL if nodes are in separate trees and do no...
void ecu_ntnode_push_child_front(struct ecu_ntnode *parent, struct ecu_ntnode *child)
Inserts a leftmost child node into the tree. child becomes parent's first (leftmost) child.
struct ecu_ntnode * ecu_ntnode_prev_sibling_iterator_at(struct ecu_ntnode_prev_sibling_iterator *me, struct ecu_ntnode *start)
Starts an iteration over all previous (left) siblings, including the supplied starting node....
const struct ecu_ntnode * ecu_ntnode_postorder_iterator_cnext(struct ecu_ntnode_postorder_citerator *me)
Const-qualified version of ecu_ntnode_postorder_iterator_next(). Returns the next node in the iterati...
const struct ecu_ntnode * ecu_ntnode_next_sibling_iterator_cbegin(struct ecu_ntnode_next_sibling_citerator *me, const struct ecu_ntnode *start)
Const-qualified version of ecu_ntnode_next_sibling_iterator_begin(). Starts an iteration over all nex...
void ecu_ntnode_insert_sibling_before(struct ecu_ntnode *pos, struct ecu_ntnode *sibling)
Inserts a sibling node into the tree before the specified position. sibling becomes pos's previous si...
const struct ecu_ntnode * ecu_ntnode_prev_sibling_iterator_cend(struct ecu_ntnode_prev_sibling_citerator *me)
Const-qualified version of ecu_ntnode_prev_sibling_iterator_end(). Returns the ending node in the ite...
void ecu_ntnode_clear(struct ecu_ntnode *me)
Removes the supplied node and all of its descendants from a tree. All nodes can be reused and added t...
struct ecu_ntnode * ecu_ntnode_last_child(struct ecu_ntnode *me)
Returns the node's last (rightmost) child. NULL is returned if the node has no children.
const struct ecu_ntnode * ecu_ntnode_next_sibling_iterator_cat(struct ecu_ntnode_next_sibling_citerator *me, const struct ecu_ntnode *start)
Const-qualified version of ecu_ntnode_next_sibling_iterator_at(). Starts an iteration over all next (...
const struct ecu_ntnode * ecu_ntnode_parent_iterator_cnext(struct ecu_ntnode_parent_citerator *me)
Const-qualified version of ecu_ntnode_parent_iterator_next(). Returns the next parent in the iteratio...
const struct ecu_ntnode * ecu_ntnode_next_sibling_iterator_cnext(struct ecu_ntnode_next_sibling_citerator *me)
Const-qualified version of ecu_ntnode_next_sibling_iterator_next(). Returns the next node in the iter...
const struct ecu_ntnode * ecu_ntnode_preorder_iterator_cnext(struct ecu_ntnode_preorder_citerator *me)
Const-qualified version of ecu_ntnode_preorder_iterator_next(). Returns the next node in the iteratio...
struct ecu_ntnode * ecu_ntnode_prev_sibling_iterator_end(struct ecu_ntnode_prev_sibling_iterator *me)
Returns the ending node in the iteration, which is NULL.
struct ecu_ntnode * ecu_ntnode_child_iterator_begin(struct ecu_ntnode_child_iterator *me, struct ecu_ntnode *parent)
Starts an iteration over the supplied node's direct children. Grandchildren, great-grandchildren,...
const struct ecu_ntnode * ecu_ntnode_postorder_iterator_cend(struct ecu_ntnode_postorder_citerator *me)
Const-qualified version of ecu_ntnode_postorder_iterator_end(). Returns the ending node in the iterat...
void ecu_ntnode_destroy(struct ecu_ntnode *me)
Node destructor. Destroys the supplied node and all of its descendants (children, grandchildren,...
struct ecu_ntnode * ecu_ntnode_next_sibling_iterator_begin(struct ecu_ntnode_next_sibling_iterator *me, struct ecu_ntnode *start)
Starts an iteration over all next (right) siblings, excluding the supplied starting node....
struct ecu_ntnode * ecu_ntnode_sibling_iterator_end(struct ecu_ntnode_sibling_iterator *me)
Returns the ending node in the iteration.
struct ecu_ntnode * ecu_ntnode_next_sibling_iterator_next(struct ecu_ntnode_next_sibling_iterator *me)
Returns the next node in the iteration.
bool ecu_ntnode_valid(const struct ecu_ntnode *me)
Returns true if supplied node has been constructed via ecu_ntnode_ctor() and can be used....
struct ecu_ntnode * ecu_ntnode_preorder_iterator_begin(struct ecu_ntnode_preorder_iterator *me, struct ecu_ntnode *root)
Starts a preorder iteration over the supplied node's tree. The supplied root is returned,...
const struct ecu_ntnode * ecu_ntnode_last_cchild(const struct ecu_ntnode *me)
Const-qualified version of ecu_ntnode_last_child(). Returns the node's last (rightmost) child....
const struct ecu_ntnode * ecu_ntnode_preorder_iterator_cend(struct ecu_ntnode_preorder_citerator *me)
Const-qualified version of ecu_ntnode_preorder_iterator_end(). Returns the ending node in the iterati...
const struct ecu_ntnode * ecu_ntnode_child_iterator_cend(struct ecu_ntnode_child_citerator *me)
Const-qualified version of ecu_ntnode_child_iterator_end(). Returns the ending node in the iteration,...
struct ecu_ntnode * ecu_ntnode_postorder_iterator_begin(struct ecu_ntnode_postorder_iterator *me, struct ecu_ntnode *root)
Starts a postorder iteration over the supplied node's tree. Returns the first node in the iteration.
void ecu_ntnode_remove(struct ecu_ntnode *me)
Removes node from a tree. If the removed node has descendants, the node becomes a new root with its t...
size_t ecu_ntnode_level(const struct ecu_ntnode *me)
Returns which level of the tree the supplied node is in. Returns 0 if the supplied node is a root.
const struct ecu_ntnode * ecu_ntnode_prev_sibling_iterator_cat(struct ecu_ntnode_prev_sibling_citerator *me, const struct ecu_ntnode *start)
Const-qualified version of ecu_ntnode_prev_sibling_iterator_at(). Starts an iteration over all previo...
struct ecu_ntnode * ecu_ntnode_prev_sibling_iterator_begin(struct ecu_ntnode_prev_sibling_iterator *me, struct ecu_ntnode *start)
Starts an iteration over all previous (left) siblings, excluding the supplied starting node....
const struct ecu_ntnode * ecu_ntnode_cnext(const struct ecu_ntnode *me)
Const-qualified version of ecu_ntnode_next(). Returns the node's next (right) sibling....
const struct ecu_ntnode * ecu_ntnode_parent_iterator_cat(struct ecu_ntnode_parent_citerator *me, const struct ecu_ntnode *start)
Const-qualified version of ecu_ntnode_parent_iterator_at(). Starts an iteration over all parents,...
struct ecu_ntnode * ecu_ntnode_child_iterator_end(struct ecu_ntnode_child_iterator *me)
Returns the ending node in the iteration, which is NULL.
struct ecu_ntnode * ecu_ntnode_prev_sibling_iterator_next(struct ecu_ntnode_prev_sibling_iterator *me)
Returns the next node in the iteration.
struct ecu_ntnode * ecu_ntnode_postorder_iterator_next(struct ecu_ntnode_postorder_iterator *me)
Returns the next node in the iteration.
const struct ecu_ntnode * ecu_ntnode_cprev(const struct ecu_ntnode *me)
Const-qualified version of ecu_ntnode_prev(). Returns the node's previous (left) sibling....
struct ecu_ntnode * ecu_ntnode_preorder_iterator_end(struct ecu_ntnode_preorder_iterator *me)
Returns the ending node in the iteration, which is a dummy delimiter.
struct ecu_ntnode * ecu_ntnode_sibling_iterator_next(struct ecu_ntnode_sibling_iterator *me)
Returns the next sibling in the iteration.
void ecu_ntnode_insert_sibling_after(struct ecu_ntnode *pos, struct ecu_ntnode *sibling)
Inserts a sibling node into the tree after the specified position. sibling becomes pos's next sibling...
const struct ecu_ntnode * ecu_ntnode_sibling_iterator_cbegin(struct ecu_ntnode_sibling_citerator *me, const struct ecu_ntnode *start)
Const-qualified version of ecu_ntnode_sibling_iterator_begin(). Starts an iteration over all siblings...
struct ecu_ntnode * ecu_ntnode_parent_iterator_begin(struct ecu_ntnode_parent_iterator *me, struct ecu_ntnode *start)
Starts an iteration over all parents, excluding the supplied starting node. If the starting node has ...
const struct ecu_ntnode * ecu_ntnode_parent_iterator_cend(struct ecu_ntnode_parent_citerator *me)
Const-qualified version of ecu_ntnode_parent_iterator_end(). Returns the ending node in the iteration...
const struct ecu_ntnode * ecu_ntnode_sibling_iterator_cnext(struct ecu_ntnode_sibling_citerator *me)
Const-qualified version of ecu_ntnode_sibling_iterator_next(). Returns the next sibling in the iterat...
struct ecu_ntnode * ecu_ntnode_next_sibling_iterator_end(struct ecu_ntnode_next_sibling_iterator *me)
Returns the ending node in the iteration, which is NULL.
const struct ecu_ntnode * ecu_ntnode_first_cchild(const struct ecu_ntnode *me)
Const-qualified version of ecu_ntnode_first_child(). Returns the node's first (leftmost) child....
struct ecu_ntnode * ecu_ntnode_parent_iterator_at(struct ecu_ntnode_parent_iterator *me, struct ecu_ntnode *start)
Starts an iteration over all parents, including the supplied starting node. The supplied starting nod...
void ecu_ntnode_push_child_back(struct ecu_ntnode *parent, struct ecu_ntnode *child)
Inserts a rightmost child node into the tree. child becomes parent's last (rightmost) child.
struct ecu_ntnode * ecu_ntnode_next_sibling_iterator_at(struct ecu_ntnode_next_sibling_iterator *me, struct ecu_ntnode *start)
Starts an iteration over all next (right) siblings, including the supplied starting node....
const struct ecu_ntnode * ecu_ntnode_postorder_iterator_cbegin(struct ecu_ntnode_postorder_citerator *me, const struct ecu_ntnode *root)
Const-qualified version of ecu_ntnode_postorder_iterator_begin(). Starts a postorder iteration over t...
const struct ecu_ntnode * ecu_ntnode_next_sibling_iterator_cend(struct ecu_ntnode_next_sibling_citerator *me)
Const-qualified version of ecu_ntnode_next_sibling_iterator_end(). Returns the ending node in the ite...
struct ecu_ntnode * ecu_ntnode_preorder_iterator_next(struct ecu_ntnode_preorder_iterator *me)
Returns the next node in the iteration.
const struct ecu_ntnode * ecu_ntnode_preorder_iterator_cbegin(struct ecu_ntnode_preorder_citerator *me, const struct ecu_ntnode *root)
Const-qualified version of ecu_ntnode_preorder_iterator_begin(). Starts a preorder iteration over the...
struct ecu_ntnode * ecu_ntnode_prev(struct ecu_ntnode *me)
Returns the node's previous (left) sibling. NULL is returned if the node is the first (leftmost) sibl...
const struct ecu_ntnode * ecu_ntnode_child_iterator_cbegin(struct ecu_ntnode_child_citerator *me, const struct ecu_ntnode *parent)
Const-qualified version of ecu_ntnode_child_iterator_begin(). Starts an iteration over the supplied n...
size_t ecu_ntnode_count(const struct ecu_ntnode *me)
Returns the number of direct children the supplied node has. Grandchildren, great-granchildren,...
int32_t ecu_object_id_t
Object ID type. Used so the library can implicitly typecast between this value, ecu_reserved_object_i...
Definition: object_id.h:64
Intrusive, doubly-linked list.
Definition: dlist.h:190
Single node within list. Intrusive, so user-defined types contain this node as a member.
Definition: dlist.h:166
Const child iterator.
Definition: ntnode.h:518
const struct ecu_ntnode * current
Current node in the iteration.
Definition: ntnode.h:520
const struct ecu_ntnode * next
Next node in the iteration. Kept to remain consistent with non-const iterator implementation.
Definition: ntnode.h:524
Non-const child iterator.
Definition: ntnode.h:502
struct ecu_ntnode * current
Current node in the iteration.
Definition: ntnode.h:504
struct ecu_ntnode * next
Next node in the iteration to allow safe removal of current node.
Definition: ntnode.h:508
Const next sibling iterator.
Definition: ntnode.h:590
const struct ecu_ntnode * current
Current node in the iteration.
Definition: ntnode.h:592
const struct ecu_ntnode * next
Next node in the iteration. Kept to remain consistent with non-const iterator implementation.
Definition: ntnode.h:596
Non-const next sibling iterator.
Definition: ntnode.h:574
struct ecu_ntnode * next
Next node in the iteration to allow safe removal of current node.
Definition: ntnode.h:580
struct ecu_ntnode * current
Current node in the iteration.
Definition: ntnode.h:576
Const parent iterator.
Definition: ntnode.h:554
const struct ecu_ntnode * current
Current node in the iteration.
Definition: ntnode.h:556
const struct ecu_ntnode * next
Next node in the iteration. Kept to remain consistent with non-const iterator implementation.
Definition: ntnode.h:560
Non-const parent iterator.
Definition: ntnode.h:538
struct ecu_ntnode * current
Current node in the iteration.
Definition: ntnode.h:540
struct ecu_ntnode * next
Next node in the iteration to allow safe removal of current node.
Definition: ntnode.h:544
Const postorder iterator.
Definition: ntnode.h:634
struct ecu_ntnode delimiter
Dummy delimiter returned at the end of the iteration. Not apart of user's tree. Allows iteration over...
Definition: ntnode.h:637
const struct ecu_ntnode * current
Current node in the iteration.
Definition: ntnode.h:644
const struct ecu_ntnode * root
Root of tree being iterated over. Included in iteration.
Definition: ntnode.h:641
const struct ecu_ntnode * next
Next node in the iteration. Kept to remain consistent with non-const iterator implementation.
Definition: ntnode.h:648
Non-const postorder iterator.
Definition: ntnode.h:610
struct ecu_ntnode * current
Current node in the iteration.
Definition: ntnode.h:620
struct ecu_ntnode delimiter
Dummy delimiter returned at the end of the iteration. Not apart of user's tree. Allows iteration over...
Definition: ntnode.h:613
struct ecu_ntnode * next
Next node in the iteration to allow safe removal of current node.
Definition: ntnode.h:624
struct ecu_ntnode * root
Root of tree being iterated over. Included in iteration.
Definition: ntnode.h:617
Const preorder iterator.
Definition: ntnode.h:682
const struct ecu_ntnode * root
Root of tree being iterated over. Included in iteration.
Definition: ntnode.h:689
struct ecu_ntnode delimiter
Dummy delimiter returned at the end of the iteration. Not apart of user's tree. Allows iteration over...
Definition: ntnode.h:685
const struct ecu_ntnode * current
Current node in the iteration.
Definition: ntnode.h:692
Non-const preorder iterator.
Definition: ntnode.h:662
struct ecu_ntnode * root
Root of tree being iterated over. Included in iteration.
Definition: ntnode.h:669
struct ecu_ntnode delimiter
Dummy delimiter returned at the end of the iteration. Not apart of user's tree. Allows iteration over...
Definition: ntnode.h:665
struct ecu_ntnode * current
Current node in the iteration.
Definition: ntnode.h:672
Const previous sibling iterator.
Definition: ntnode.h:722
const struct ecu_ntnode * next
Next node in the iteration. Kept to remain consistent with non-const iterator implementation.
Definition: ntnode.h:728
const struct ecu_ntnode * current
Current node in the iteration.
Definition: ntnode.h:724
Non-const previous sibling iterator.
Definition: ntnode.h:706
struct ecu_ntnode * current
Current node in the iteration.
Definition: ntnode.h:708
struct ecu_ntnode * next
Next node in the iteration to allow safe removal of current node.
Definition: ntnode.h:712
Const sibling iterator.
Definition: ntnode.h:763
const struct ecu_ntnode * end
Starting node of iteration which is also the ending node. Not included in iteration to allow safe rem...
Definition: ntnode.h:767
const struct ecu_ntnode * next
Next node in the iteration. Kept to remain consistent with non-const iterator implementation.
Definition: ntnode.h:774
const struct ecu_ntnode * current
Current node in the iteration.
Definition: ntnode.h:770
Non-const sibling iterator.
Definition: ntnode.h:742
struct ecu_ntnode * current
Current node in the iteration.
Definition: ntnode.h:749
struct ecu_ntnode * next
Next node in the iteration to allow safe removal of current node.
Definition: ntnode.h:753
struct ecu_ntnode * end
Starting node of iteration which is also the ending node. Not included in iteration to allow safe rem...
Definition: ntnode.h:746
Single node within a tree. Intrusive, so user-defined types contain this node as a member....
Definition: ntnode.h:475
struct ecu_ntnode * parent
Node's parent.
Definition: ntnode.h:483
void(* destroy)(struct ecu_ntnode *me, ecu_object_id_t id)
Optional user-defined node destructor. Executes when ecu_ntnode_destroy() is called or if this node w...
Definition: ntnode.h:488
struct ecu_dlist children
Node's children, represented as a linked list.
Definition: ntnode.h:480
struct ecu_dnode dnode
This node, represented as a linked list node.
Definition: ntnode.h:477