2
3
4
5
6
7
8
9
10
12#ifndef GIMBAL_NARY_TREE_H
13#define GIMBAL_NARY_TREE_H
15#include "../core/gimbal_ctx.h"
18#define GBL_NARY_TREE_ENTRY(node, structure, field) GBL_CONTAINER_OF(node, structure, field)
19#define GBL_NARY_TREE_TRAVERSAL_MASK(order, flags) ((order << 0x3
) | (flags))
21#define GBL_SELF_TYPE GblNaryTreeNode
27typedef GblBool (*GblNaryTreeIterFn)(
const GblNaryTreeNode* pNode,
void* pUd);
29typedef enum GBL_NARY_TREE_NODE_FLAGS {
30 GBL_NARY_TREE_NODE_FLAG_ROOT = 0x1,
31 GBL_NARY_TREE_NODE_FLAG_INTERNAL = 0x2,
32 GBL_NARY_TREE_NODE_FLAG_LEAF = 0x4,
33 GBL_NARY_TREE_NODE_FLAGS_ALL = 0x7
34} GBL_NARY_TREE_NODE_FLAGS;
36typedef enum GBL_NARY_TREE_TRAVERSAL_ORDER {
37 GBL_NARY_TREE_TRAVERSAL_ORDER_PRE,
38 GBL_NARY_TREE_TRAVERSAL_ORDER_IN,
39 GBL_NARY_TREE_TRAVERSAL_ORDER_POST,
40 GBL_NARY_TREE_TRAVERSAL_ORDER_LEVEL
41} GBL_NARY_TREE_TRAVERSAL_ORDER;
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#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)