1#ifndef NW4R_UT_LINKLIST_H
2#define NW4R_UT_LINKLIST_H
3#include <nw4r/types_nw4r.h>
20void List_Init(
List* pList, u16 offset);
22void List_Append(
List* pList,
void* pObject);
23void List_Prepend(
List* pList,
void* pObject);
25void List_Insert(
List* pList,
void* pTarget,
void* pObject);
26void List_Remove(
List* pList,
void* pObject);
28void* List_GetNext(
const List* pList,
const void* pObject);
29inline const void* List_GetNextConst(
const List* pList,
const void* pObject) {
30 return List_GetNext(pList, pObject);
33void* List_GetPrev(
const List* pList,
const void* pObject);
34inline const void* List_GetPrevConst(
const List* pList,
const void* pObject) {
35 return List_GetPrev(pList, pObject);
38void* List_GetNth(
const List* pList, u16 n);
39inline const void* List_GetNthConst(
const List* pList, u16 n) {
40 return List_GetNth(pList, n);
43inline void* List_GetFirst(
const List* pList) {
44 return List_GetNext(pList, NULL);
46inline const void* List_GetFirstConst(
const List* pList) {
47 return List_GetFirst(pList);
50inline void* List_GetLast(
const List* pList) {
51 return List_GetPrev(pList, NULL);
53inline const void* List_GetLastConst(
const List* pList) {
54 return List_GetLast(pList);
57inline u16 List_GetSize(
const List* pList) {
58 return pList->numObjects;
69#define NW4R_UT_LIST_LINK_DECL() nw4r::ut::Link link
77#define NW4R_UT_LIST_INIT(LIST, T) \
78 nw4r::ut::List_Init(&(LIST), offsetof(T, link))
86#define NW4R_UT_LIST_GET_LINK(LIST, OBJ) \
87 reinterpret_cast<nw4r::ut::Link*>((u8*)(OBJ) + (LIST).offset)
97#define NW4R_UT_LIST_FOREACH(TYPE, NAME, LIST, ...) \
101 while ((NAME = static_cast<TYPE*>( \
102 nw4r::ut::List_GetNext(&(LIST), NAME))) != NULL) { \
115#define NW4R_UT_LIST_FOREACH_REV(TYPE, NAME, LIST, ...) \
119 while ((NAME = static_cast<TYPE*>( \
120 nw4r::ut::List_GetPrev(&(LIST), NAME))) != NULL) { \
134#define NW4R_UT_LIST_FOREACH_SAFE(TYPE, NAME, LIST, ...) \
139 for (NAME = static_cast<TYPE*>(nw4r::ut::List_GetFirst(&(LIST))); \
140 NAME != NULL; NAME = __next__) { \
143 static_cast<TYPE*>(nw4r::ut::List_GetNext(&(LIST), NAME)); \
Debugging library which includes various utilities used by the rest of nw4r.