NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
c_tree.hpp
1#pragma once
2#include <types.h>
3
4/// @brief A tree node. See cTreeMg_c.
5/// @ingroup clib
6/// @details The tree is represented as a doubly-linked LCRS tree.
7class cTreeNd_c {
8public:
9 /// @brief Constructs a new tree node.
10 cTreeNd_c();
11
12 /// @brief Gets the next node in preorder traversal order.
13 cTreeNd_c *getTreeNext() const;
14
15 /// @brief Gets the next node in preorder traversal order, excluding the node's children.
17
18 cTreeNd_c *getParent() const { return mpParent; }
19 cTreeNd_c *getChild() const { return mpChild; }
20 cTreeNd_c *getBrPrev() const { return mpPrev; }
21 cTreeNd_c *getBrNext() const { return mpNext; }
22
23protected:
24 /// @brief Clears all fields.
25 void forcedClear();
26
27 cTreeNd_c *mpParent; ///< The parent node.
28 cTreeNd_c *mpChild; ///< The child node.
29 cTreeNd_c *mpPrev; ///< The previous sibling node.
30 cTreeNd_c *mpNext; ///< The next sibling node.
31
32 friend class cTreeMg_c;
33};
34
35/// @brief A tree container. See cTreeNd_c.
36/// @ingroup clib
37class cTreeMg_c {
38public:
39 /// @brief Constructs a new tree container.
40 cTreeMg_c() : mpRootNode(nullptr) {}
41
42 /**
43 * @brief Adds a node to the tree, either to the root node or to a specified parent node.
44 *
45 * @param node The node to add.
46 * @param parent The parent node to attach it to, or @p nullptr to attach it to the tree root.
47 * @return If the operation was successful.
48 */
49 bool addTreeNode(cTreeNd_c *node, cTreeNd_c *parent);
50
51 /**
52 * @brief Removes a node from the tree.
53 *
54 * @param node The node to remove.
55 * @return If the operation was successful.
56 */
57 bool removeTreeNode(cTreeNd_c *node);
58
59protected:
60 cTreeNd_c *mpRootNode; ///< The root node of the tree.
61};
cTreeMg_c()
Constructs a new tree container.
Definition c_tree.hpp:40
bool addTreeNode(cTreeNd_c *node, cTreeNd_c *parent)
Adds a node to the tree, either to the root node or to a specified parent node.
Definition c_tree.cpp:15
cTreeNd_c * mpRootNode
The root node of the tree.
Definition c_tree.hpp:60
bool removeTreeNode(cTreeNd_c *node)
Removes a node from the tree.
Definition c_tree.cpp:57
A tree node. See cTreeMg_c.
Definition c_tree.hpp:7
cTreeNd_c * mpParent
The parent node.
Definition c_tree.hpp:27
void forcedClear()
Clears all fields.
Definition c_tree.cpp:8
cTreeNd_c * mpPrev
The previous sibling node.
Definition c_tree.hpp:29
cTreeNd_c()
Constructs a new tree node.
Definition c_tree.cpp:4
cTreeNd_c * getTreeNextNotChild() const
Gets the next node in preorder traversal order, excluding the node's children.
Definition c_tree.cpp:103
cTreeNd_c * mpChild
The child node.
Definition c_tree.hpp:28
cTreeNd_c * mpNext
The next sibling node.
Definition c_tree.hpp:30
cTreeNd_c * getTreeNext() const
Gets the next node in preorder traversal order.
Definition c_tree.cpp:92