This commit is contained in:
lepelog
2023-08-09 16:59:04 +02:00
commit 42880ec9ae
195 changed files with 61297 additions and 0 deletions
+70
View File
@@ -0,0 +1,70 @@
#pragma once
// This file was ported from https://github.com/NSMBW-Community/NSMBW-Decomp/blob/master/include/dol/cLib/c_list.hpp
#include <types.h>
/// @brief A doubly-linked list node. See cListMg_c.
/// @note Unofficial name.
class cListNd_c {
public:
/// @brief Constructs a new list node.
cListNd_c() : mpPrev(nullptr), mpNext(nullptr) {}
cListNd_c *getPrev() const { return mpPrev; }
cListNd_c *getNext() const { return mpNext; }
protected:
cListNd_c *mpPrev; ///< The previous node.
cListNd_c *mpNext; ///< The next node.
friend class cListMg_c;
};
/// @brief A doubly-linked list container. See cListNd_c.
/// @note Unofficial name.
class cListMg_c {
public:
/// @brief Constructs a new list container.
cListMg_c() : mpFirst(nullptr), mpLast(nullptr) {}
/**
* @brief Inserts a node after the given previous node.
*
* @param node The node to insert.
* @param prevNode The node to insert it after, or @p nullptr to insert it at the beginning.
* @return If the operation was successful.
*/
bool insertAfter(cListNd_c *node, cListNd_c *prevNode);
/**
* @brief Removes a node from the list.
*
* @param node The node to remove.
* @return If the operation was successful.
*/
bool remove(cListNd_c *node);
/**
* @brief Adds a node to the end of the list.
*
* @param node The node to append.
* @return If the operation was successful.
*/
bool append(cListNd_c *node);
/**
* @brief Adds a node to the beginning of the list.
*
* @param node The node to prepend.
* @return If the operation was successful.
*/
bool prepend(cListNd_c *node);
cListNd_c *getFirst() const { return mpFirst; }
cListNd_c *getLast() const { return mpLast; }
protected:
cListNd_c *mpFirst; ///< The first node in the list.
cListNd_c *mpLast; ///< The last node in the list.
};
+54
View File
@@ -0,0 +1,54 @@
#pragma once
// This file was ported from https://github.com/NSMBW-Community/NSMBW-Decomp/blob/master/include/dol/cLib/c_owner_set.hpp
#include <types.h>
/// @file
/// @brief A set node with a pointer to the owning container. See cOwnerSetMg_c.
/// @note Unofficial name.
class cOwnerSetNd_c {
public:
void *getOwner() const { return mpOwner; }
cOwnerSetNd_c *getNext() const { return mpNext; }
private:
void* mpOwner; ///< The set that contains this node.
cOwnerSetNd_c* mpNext; ///< The next node in the set.
friend class cOwnerSetMg_c;
};
/// @brief A set container. See cOwnerSetNd_c.
/// @details The set is implemented as a singly-linked list.
/// @note Unofficial name.
class cOwnerSetMg_c {
public:
/// @brief Constructs a new set container.
cOwnerSetMg_c() : mpRoot(nullptr) {}
/// @brief Destroys the set.
~cOwnerSetMg_c() { clear(); };
/**
* @brief Adds a node to the set.
*
* @param nd The node to add.
* @param owner The owner of the node.
*/
void add(cOwnerSetNd_c *nd, void *owner);
/**
* @brief Removes a node from the set.
*
* @param nd The node to remove.
* @param owner The owner of the node.
*/
void remove(cOwnerSetNd_c *nd, void *owner);
private:
/// @brief Clears out the set and unlinks all child nodes.
void clear();
cOwnerSetNd_c* mpRoot; ///< The first element of the set.
};
+62
View File
@@ -0,0 +1,62 @@
#pragma once
// This file was ported from https://github.com/NSMBW-Community/NSMBW-Decomp/blob/master/include/dol/cLib/c_tree.hpp
#include <types.h>
/// @brief A tree node. See cTreeMg_c.
/// @details The tree is represented as a doubly-linked LCRS tree.
class cTreeNd_c {
public:
/// @brief Constructs a new tree node.
cTreeNd_c();
/// @brief Gets the next node in preorder traversal order.
cTreeNd_c *getTreeNext() const;
/// @brief Gets the next node in preorder traversal order, excluding the node's children.
cTreeNd_c *getTreeNextNotChild() const;
cTreeNd_c *getParent() const { return mpParent; }
cTreeNd_c *getChild() const { return mpChild; }
cTreeNd_c *getBrPrev() const { return mpPrev; }
cTreeNd_c *getBrNext() const { return mpNext; }
protected:
/// @brief Clears all fields.
void forcedClear();
cTreeNd_c *mpParent; ///< The parent node.
cTreeNd_c *mpChild; ///< The child node.
cTreeNd_c *mpPrev; ///< The previous sibling node.
cTreeNd_c *mpNext; ///< The next sibling node.
friend class cTreeMg_c;
};
/// @brief A tree container. See cTreeNd_c.
class cTreeMg_c {
public:
/// @brief Constructs a new tree container.
cTreeMg_c() : mpRootNode(nullptr) {}
/**
* @brief Adds a node to the tree, either to the root node or to a specified parent node.
*
* @param node The node to add.
* @param parent The parent node to attach it to, or @p nullptr to attach it to the tree root.
* @return If the operation was successful.
*/
bool addTreeNode(cTreeNd_c *node, cTreeNd_c *parent);
/**
* @brief Removes a node from the tree.
*
* @param node The node to remove.
* @return If the operation was successful.
*/
bool removeTreeNode(cTreeNd_c *node);
protected:
cTreeNd_c *mpRootNode; ///< The root node of the tree.
};