Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
Loading...
Searching...
No Matches
JPAList.h
Go to the documentation of this file.
1#ifndef JPALIST_H
2#define JPALIST_H
3
4#include "dolphin/types.h"
5
10template <class T>
11struct JPANode {
13 mpPrev = NULL;
14 mpNext = NULL;
15 }
17 JPANode<T>* getPrev() { return mpPrev; }
18 JPANode<T>* getNext() { return mpNext; }
19 T* getObject() { return &mData; }
20
21 /* 0x00 */ JPANode<T>* mpPrev;
22 /* 0x04 */ JPANode<T>* mpNext;
23 /* 0x08 */ T mData;
24};
25
30template <class T>
31struct JPAList {
32 /* 0x00 */ JPANode<T>* mpFirst;
33 /* 0x04 */ JPANode<T>* mpLast;
34 /* 0x08 */ u32 mNum;
35
37
38 JPANode<T>* getEnd() { return NULL; }
39 JPANode<T>* getFirst() const { return mpFirst; }
40 JPANode<T>* getLast() const { return mpLast; }
41 u32 getNum() const { return mNum; }
42
43 void push_front(JPANode<T>* node) {
44 if (mpFirst != NULL) {
45 node->mpPrev = NULL;
46 node->mpNext = mpFirst;
47 mpFirst->mpPrev = node;
48 mpFirst = node;
49 } else {
50 mpLast = node;
51 mpFirst = node;
52 node->mpPrev = NULL;
53 node->mpNext = NULL;
54 }
55
56 mNum++;
57 }
58
59 void push_back(JPANode<T>* node) {
60 if (mpLast != NULL) {
61 node->mpPrev = mpLast;
62 node->mpNext = NULL;
63 mpLast->mpNext = node;
64 mpLast = node;
65 } else {
66 mpFirst = node;
67 mpLast = node;
68 node->mpPrev = NULL;
69 node->mpNext = NULL;
70 }
71
72 mNum++;
73 }
74
76 JPANode<T>* ret = NULL;
77
78 if (mNum == 1) {
79 ret = mpFirst;
80 mpLast = NULL;
81 mpFirst = NULL;
82 mNum--;
83 } else if (mNum) {
84 ret = mpFirst;
85 ret->mpNext->mpPrev = NULL;
86 mpFirst = ret->mpNext;
87 mNum--;
88 }
89
90 return ret;
91 }
92
94 JPANode<T>* ret = NULL;
95
96 if (mNum == 1) {
97 ret = mpLast;
98 mpLast = NULL;
99 mpFirst = NULL;
100 mNum--;
101 } else if (mNum) {
102 ret = mpLast;
103 ret->mpPrev->mpNext = NULL;
104 mpLast = ret->mpPrev;
105 mNum--;
106 }
107
108 return ret;
109 }
110
112 if (node->mpNext != NULL && node->mpPrev != NULL) {
113 node->mpPrev->mpNext = node->mpNext;
114 node->mpNext->mpPrev = node->mpPrev;
115 mNum--;
116 } else if (node->mpNext != NULL) {
117 node->mpNext->mpPrev = NULL;
118 mpFirst = node->mpNext;
119 mNum--;
120 } else if (node->mpPrev != NULL) {
121 node->mpPrev->mpNext = NULL;
122 mpLast = node->mpPrev;
123 mNum--;
124 } else {
125 mpLast = NULL;
126 mpFirst = NULL;
127 mNum--;
128 }
129 return node;
130 }
131};
132
133#endif
T cLib_calcTimer(T *value)
Definition c_lib.h:74
static const double T[]
Definition k_tan.c:106
Definition JPAList.h:31
JPANode< T > * mpLast
Definition JPAList.h:33
JPANode< T > * getLast() const
Definition JPAList.h:40
void push_front(JPANode< T > *node)
Definition JPAList.h:43
JPANode< T > * getEnd()
Definition JPAList.h:38
JPANode< T > * pop_back()
Definition JPAList.h:93
JPAList()
Definition JPAList.h:36
void push_back(JPANode< T > *node)
Definition JPAList.h:59
JPANode< T > * erase(JPANode< T > *node)
Definition JPAList.h:111
JPANode< T > * getFirst() const
Definition JPAList.h:39
JPANode< T > * pop_front()
Definition JPAList.h:75
u32 mNum
Definition JPAList.h:34
JPANode< T > * mpFirst
Definition JPAList.h:32
u32 getNum() const
Definition JPAList.h:41
Definition JPAList.h:11
JPANode()
Definition JPAList.h:12
JPANode< T > * mpPrev
Definition JPAList.h:21
~JPANode()
Definition JPAList.h:16
JPANode< T > * mpNext
Definition JPAList.h:22
T * getObject()
Definition JPAList.h:19
T mData
Definition JPAList.h:23
JPANode< T > * getPrev()
Definition JPAList.h:17
JPANode< T > * getNext()
Definition JPAList.h:18
unsigned long u32
Definition types.h:10