NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
list.hpp
Go to the documentation of this file.
1#pragma once
2#include <types.h>
3///@file
4
5namespace nw4r {
6namespace ut {
7
8/// @brief A doubly-linked list node. See List.
9struct Link {
10 void *mpPrev; ///< The previous linked object.
11 void *mpNext; ///< The next linked object.
12};
13
14/// @brief A doubly-linked list container. See Link.
15struct List {
16 void *mpHead; ///< The first linked object.
17 void *mpTail; ///< The last linked object.
18 u16 mCount; ///< The linked object count.
19 u16 mOffset; ///< The offset of the Link structure in each object.
20};
21
22void List_Init(List *list, u16 offset); ///< Initializes the list.
23void List_Append(List *list, void *obj); ///< Adds an object to the end of the list.
24void List_Prepend(List *list, void *obj); ///< Adds an object to the beginning of the list.
25
26/// @brief Inserts an object at a specified position in the list.
27/// @details If @p target is not @p nullptr , @p obj is inserted in front of @p target ,
28/// else it is added at the end of the list.
29void List_Insert(List *list, void *target, void *obj);
30
31void List_Remove(List *list, void *obj); ///< Deletes an object from the list.
32
33/// @brief Gets the object linked after the given one.
34/// @details If @p obj is @p nullptr , the list's head object is returned.
35void *List_GetNext(const List *list, const void *obj);
36
37/// @brief Gets the object linked before the given one.
38/// @details If @p obj is @p nullptr , the list's tail object is returned.
39void *List_GetPrev(const List *list, const void *obj);
40
41} // namespace ut
42} // namespace nw4r
Debugging library which includes various utilities used by the rest of nw4r.
Definition list.cpp:4
void List_Append(List *list, void *obj)
Adds an object to the end of the list.
Definition list.cpp:15
void List_Prepend(List *list, void *obj)
Adds an object to the beginning of the list.
Definition list.cpp:40
void List_Remove(List *list, void *obj)
Deletes an object from the list.
Definition list.cpp:93
void * List_GetPrev(const List *list, const void *obj)
Gets the object linked before the given one.
Definition list.cpp:128
void List_Init(List *list, u16 offset)
Initializes the list.
Definition list.cpp:8
void * List_GetNext(const List *list, const void *obj)
Gets the object linked after the given one.
Definition list.cpp:120
void List_Insert(List *list, void *target, void *obj)
Inserts an object at a specified position in the list.
Definition list.cpp:65
A doubly-linked list container. See Link.
Definition list.hpp:15
void * mpHead
The first linked object.
Definition list.hpp:16
u16 mCount
The linked object count.
Definition list.hpp:18
u16 mOffset
The offset of the Link structure in each object.
Definition list.hpp:19
void * mpTail
The last linked object.
Definition list.hpp:17