2
3
4
5
6
7
9#ifndef GIMBAL_NARY_TREE_H
10#define GIMBAL_NARY_TREE_H
12#include "../core/gimbal_ctx.h"
15#define GBL_NARY_TREE_ENTRY(node, structure, field) GBL_CONTAINER_OF(node, structure, field)
16#define GBL_NARY_TREE_TRAVERSAL_MASK(order, flags) ((order << 0x3
) | (flags))
18#define GBL_SELF_TYPE GblNaryTreeNode
24typedef GblBool (*GblNaryTreeIterFn)(
const GblNaryTreeNode* pNode,
void* pUd);
26typedef enum GBL_NARY_TREE_NODE_FLAGS {
27 GBL_NARY_TREE_NODE_FLAG_ROOT = 0x1,
28 GBL_NARY_TREE_NODE_FLAG_INTERNAL = 0x2,
29 GBL_NARY_TREE_NODE_FLAG_LEAF = 0x4,
30 GBL_NARY_TREE_NODE_FLAGS_ALL = 0x7
31} GBL_NARY_TREE_NODE_FLAGS;
33typedef enum GBL_NARY_TREE_TRAVERSAL_ORDER {
34 GBL_NARY_TREE_TRAVERSAL_ORDER_PRE,
35 GBL_NARY_TREE_TRAVERSAL_ORDER_IN,
36 GBL_NARY_TREE_TRAVERSAL_ORDER_POST,
37 GBL_NARY_TREE_TRAVERSAL_ORDER_LEVEL
38} GBL_NARY_TREE_TRAVERSAL_ORDER;
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#define GBL_FORWARD_DECLARE_STRUCT(S)
#define GBL_CONTAINER_OF(ptr, type, member)
uint32_t GblFlags
Standard-sized flags type, 32-bits across platforms.
uint8_t GblBool
Basic boolean type, standardized to sizeof(char)
Represents a single intrusive node within an N-Ary tree structure.
struct GblNaryTreeNode * pParent
Node's parent.
struct GblNaryTreeNode * pSiblingNext
Node's next sibling (next entry of child linked list)
struct GblNaryTreeNode * pChildFirst
Node's first child (beginning of child linked list)