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 {
12 JPANode() : mpPrev(NULL), mpNext(NULL) {
13 }
15 JPANode<T>* getPrev() { return mpPrev; }
16 JPANode<T>* getNext() { return mpNext; }
17 T* getObject() { return &mData; }
18
19 /* 0x00 */ JPANode<T>* mpPrev;
20 /* 0x04 */ JPANode<T>* mpNext;
21 /* 0x08 */ T mData;
22};
23
28template <class T>
29struct JPAList {
30 /* 0x00 */ JPANode<T>* mpFirst;
31 /* 0x04 */ JPANode<T>* mpLast;
32 /* 0x08 */ u32 mNum;
33
34 JPAList() : mpFirst(NULL), mpLast(NULL), mNum() {}
36
37 JPANode<T>* getEnd() { return NULL; }
38 JPANode<T>* getFirst() const { return mpFirst; }
39 JPANode<T>* getLast() const { return mpLast; }
40 u32 getNum() const { return mNum; }
41
42 void push_front(JPANode<T>* node) {
43 if (mpFirst != NULL) {
44 node->mpPrev = NULL;
45 node->mpNext = mpFirst;
46 mpFirst->mpPrev = node;
47 mpFirst = node;
48 } else {
49 mpLast = node;
50 mpFirst = node;
51 node->mpPrev = NULL;
52 node->mpNext = NULL;
53 }
54
55 mNum++;
56 }
57
58 void push_back(JPANode<T>* node) {
59 if (mpLast != NULL) {
60 node->mpPrev = mpLast;
61 node->mpNext = NULL;
62 mpLast->mpNext = node;
63 mpLast = node;
64 } else {
65 mpFirst = node;
66 mpLast = node;
67 node->mpNext = node->mpPrev = NULL;
68 }
69
70 mNum++;
71 }
72
74 JPANode<T>* ret = NULL;
75
76 if (mNum == 1) {
77 ret = mpFirst;
78 mpLast = NULL;
79 mpFirst = NULL;
80 mNum--;
81 } else if (mNum) {
82 ret = mpFirst;
83 ret->mpNext->mpPrev = NULL;
84 mpFirst = ret->mpNext;
85 mNum--;
86 }
87
88 return ret;
89 }
90
92 JPANode<T>* ret = NULL;
93
94 if (mNum == 1) {
95 ret = mpLast;
96 mpLast = NULL;
97 mpFirst = NULL;
98 mNum--;
99 } else if (mNum) {
100 ret = mpLast;
101 ret->mpPrev->mpNext = NULL;
102 mpLast = ret->mpPrev;
103 mNum--;
104 }
105
106 return ret;
107 }
108
110 if (node->mpNext != NULL && node->mpPrev != NULL) {
111 node->mpPrev->mpNext = node->mpNext;
112 node->mpNext->mpPrev = node->mpPrev;
113 mNum--;
114 } else if (node->mpNext != NULL) {
115 node->mpNext->mpPrev = NULL;
116 mpFirst = node->mpNext;
117 mNum--;
118 } else if (node->mpPrev != NULL) {
119 node->mpPrev->mpNext = NULL;
120 mpLast = node->mpPrev;
121 mNum--;
122 } else {
123 mpLast = NULL;
124 mpFirst = NULL;
125 mNum--;
126 }
127 return node;
128 }
129};
130
131#endif
unsigned long u32
Definition types.h:12
Definition JPAList.h:29
JPANode< T > * mpLast
Definition JPAList.h:31
JPANode< T > * getLast() const
Definition JPAList.h:39
void push_front(JPANode< T > *node)
Definition JPAList.h:42
JPANode< T > * getEnd()
Definition JPAList.h:37
JPANode< T > * pop_back()
Definition JPAList.h:91
JPAList()
Definition JPAList.h:34
void push_back(JPANode< T > *node)
Definition JPAList.h:58
~JPAList()
Definition JPAList.h:35
JPANode< T > * erase(JPANode< T > *node)
Definition JPAList.h:109
JPANode< T > * getFirst() const
Definition JPAList.h:38
JPANode< T > * pop_front()
Definition JPAList.h:73
u32 mNum
Definition JPAList.h:32
JPANode< T > * mpFirst
Definition JPAList.h:30
u32 getNum() const
Definition JPAList.h:40
Definition JPAList.h:11
JPANode()
Definition JPAList.h:12
JPANode< T > * mpPrev
Definition JPAList.h:19
~JPANode()
Definition JPAList.h:14
JPANode< T > * mpNext
Definition JPAList.h:20
T * getObject()
Definition JPAList.h:17
T mData
Definition JPAList.h:21
JPANode< T > * getPrev()
Definition JPAList.h:15
JPANode< T > * getNext()
Definition JPAList.h:16