NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
c_list.hpp
1#pragma once
2#include <types.h>
3
4/// @brief A doubly-linked list node. See cListMg_c.
5/// @ingroup clib
6/// @unofficial
7class cListNd_c {
8public:
9 /// @brief Constructs a new list node.
10 cListNd_c() : mpPrev(nullptr), mpNext(nullptr) {}
11
12 cListNd_c *getPrev() const { return mpPrev; }
13 cListNd_c *getNext() const { return mpNext; }
14
15protected:
16 cListNd_c *mpPrev; ///< The previous node.
17 cListNd_c *mpNext; ///< The next node.
18
19 friend class cListMg_c;
20};
21
22/// @brief A doubly-linked list container. See cListNd_c.
23/// @ingroup clib
24/// @unofficial
25class cListMg_c {
26public:
27 /// @brief Constructs a new list container.
28 cListMg_c() : mpFirst(nullptr), mpLast(nullptr) {}
29
30 /**
31 * @brief Inserts a node after the given previous node.
32 *
33 * @param node The node to insert.
34 * @param prevNode The node to insert it after, or @p nullptr to insert it at the beginning.
35 * @return If the operation was successful.
36 */
37 bool insertAfter(cListNd_c *node, cListNd_c *prevNode);
38
39 /**
40 * @brief Removes a node from the list.
41 *
42 * @param node The node to remove.
43 * @return If the operation was successful.
44 */
45 bool remove(cListNd_c *node);
46
47 /**
48 * @brief Adds a node to the end of the list.
49 *
50 * @param node The node to append.
51 * @return If the operation was successful.
52 */
53 bool append(cListNd_c *node);
54
55 /**
56 * @brief Adds a node to the beginning of the list.
57 *
58 * @param node The node to prepend.
59 * @return If the operation was successful.
60 */
61 bool prepend(cListNd_c *node);
62
63 cListNd_c *getFirst() const { return mpFirst; }
64 cListNd_c *getLast() const { return mpLast; }
65
66protected:
67 cListNd_c *mpFirst; ///< The first node in the list.
68 cListNd_c *mpLast; ///< The last node in the list.
69};
cListMg_c()
Constructs a new list container.
Definition c_list.hpp:28
bool append(cListNd_c *node)
Adds a node to the end of the list.
Definition c_list.cpp:60
bool remove(cListNd_c *node)
Removes a node from the list.
Definition c_list.cpp:30
cListNd_c * mpFirst
The first node in the list.
Definition c_list.hpp:67
cListNd_c * mpLast
The last node in the list.
Definition c_list.hpp:68
bool prepend(cListNd_c *node)
Adds a node to the beginning of the list.
Definition c_list.cpp:80
bool insertAfter(cListNd_c *node, cListNd_c *prevNode)
Inserts a node after the given previous node.
Definition c_list.cpp:4
A doubly-linked list node. See cListMg_c.
Definition c_list.hpp:7
cListNd_c * mpNext
The next node.
Definition c_list.hpp:17
cListNd_c()
Constructs a new list node.
Definition c_list.hpp:10
cListNd_c * mpPrev
The previous node.
Definition c_list.hpp:16