Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
Loading...
Searching...
No Matches
JSUList.h
Go to the documentation of this file.
1#ifndef JSULIST_H
2#define JSULIST_H
3
4#include <dolphin/types.h>
5
6template <typename T>
7class JSUList;
8
9//
10// Link
11//
12
13class JSUPtrList;
14
20public:
21 JSUPtrLink(void* object);
23
24 void* getObjectPtr() const { return mObject; }
25
26 JSUPtrList* getList() const { return mList; }
27
28 JSUPtrLink* getNext() const { return mNext; }
29
30 JSUPtrLink* getPrev() const { return mPrev; }
31
32public:
33 void* mObject;
37};
38
43template <typename T>
44class JSULink : public JSUPtrLink {
45public:
46 JSULink(T* object) : JSUPtrLink((void*)object) {}
47
48 T* getObject() const { return static_cast<T*>(mObject); }
49
50 JSUList<T>* getSupervisor() const { return static_cast<JSUList<T>*>(mList); }
51
52 JSULink<T>* getNext() const { return static_cast<JSULink*>(mNext); }
53
54 JSULink<T>* getPrev() const { return static_cast<JSULink*>(mPrev); }
55};
56
57//
58// List
59//
60
66public:
67 JSUPtrList() { this->initiate(); }
68 JSUPtrList(bool init);
70
71 void initiate();
72 void setFirst(JSUPtrLink* first);
73 bool append(JSUPtrLink* ptr);
74 bool prepend(JSUPtrLink* ptr);
75 bool insert(JSUPtrLink* before, JSUPtrLink* ptr);
76 bool remove(JSUPtrLink* ptr);
77 JSUPtrLink* getNthLink(u32 i) const;
78
79 JSUPtrLink* getFirstLink() const { return mHead; }
80
81 JSUPtrLink* getLastLink() const { return mTail; }
82
83 u32 getNumLinks() const { return mLength; }
84
85protected:
89};
90
95template <typename T>
96class JSUList : public JSUPtrList {
97public:
100
102
104
105 bool append(JSULink<T>* link) { return this->JSUPtrList::append((JSUPtrLink*)link); }
106
107 bool prepend(JSULink<T>* link) { return this->JSUPtrList::prepend((JSUPtrLink*)link); }
108
109 bool insert(JSULink<T>* before, JSULink<T>* link) {
110 return this->JSUPtrList::insert((JSUPtrLink*)before, (JSUPtrLink*)link);
111 }
112
113 bool remove(JSULink<T>* link) { return this->JSUPtrList::remove((JSUPtrLink*)link); }
114
116
117 JSULink<T>* getLast() const { return (JSULink<T>*)getLastLink(); }
118
120
121 JSULink<T>* getEnd() const { return NULL; }
122
123 u32 getNumLinks() const { return mLength; }
124};
125
130template <typename T>
132public:
135 JSUListIterator(JSUList<T>* list) : mLink(list->getFirst()) {}
136
138 this->mLink = link;
139 return *this;
140 }
141
142 T* getObject() const { return this->mLink->getObject(); }
143
144 bool operator==(JSULink<T> const* other) const { return this->mLink == other; }
145 bool operator!=(JSULink<T> const* other) const { return this->mLink != other; }
146 bool operator==(JSUListIterator<T> const& other) const { return this->mLink == other.mLink; }
147 bool operator!=(JSUListIterator<T> const& other) const { return this->mLink != other.mLink; }
148
150 JSUListIterator<T> prev = *this;
151 this->mLink = this->mLink->getNext();
152 return prev;
153 }
154
156 this->mLink = this->mLink->getNext();
157 return *this;
158 }
159
161 JSUListIterator<T> prev = *this;
162 this->mLink = this->mLink->getPrev();
163 return prev;
164 }
165
167 this->mLink = this->mLink->getPrev();
168 return *this;
169 }
170
171 T& operator*() { return *this->getObject(); }
172
173 T* operator->() const { return mLink->getObject(); }
174
175// private:
177};
178
179//
180// Tree
181//
182
187template <typename T>
188class JSUTree : public JSUList<T>, public JSULink<T> {
189public:
190 JSUTree(T* owner) : JSUList<T>(), JSULink<T>(owner) {}
192
193 bool appendChild(JSUTree<T>* child) { return this->append(child); }
194
195 bool prependChild(JSUTree<T>* child) { return this->prepend(child); }
196
197 bool removeChild(JSUTree<T>* child) { return this->remove(child); }
198
199 bool insertChild(JSUTree<T>* before, JSUTree<T>* child) { return this->insert(before, child); }
200
201 JSUTree<T>* getEndChild() const { return NULL; }
202
203 JSUTree<T>* getFirstChild() const { return (JSUTree<T>*)this->getFirstLink(); }
204
205 JSUTree<T>* getLastChild() const { return (JSUTree<T>*)this->getLastLink(); }
206
207 JSUTree<T>* getNextChild() const { return (JSUTree<T>*)this->mNext; }
208
209 JSUTree<T>* getPrevChild() const { return (JSUTree<T>*)this->mPrev; }
210
211 u32 getNumChildren() const { return this->getNumLinks(); }
212
213 T* getObject() const { return (T*)this->mObject; }
214
215 JSUTree<T>* getParent() const { return (JSUTree<T>*)this->mList; }
216};
217
222template <typename T>
224public:
227
229 this->mTree = tree;
230 return *this;
231 }
232
233 T* getObject() const { return this->mTree->getObject(); }
234
235 bool operator==(const JSUTree<T>* other) const { return this->mTree == other; }
236
237 bool operator!=(const JSUTree<T>* other) const { return this->mTree != other; }
238
240 JSUTreeIterator<T> prev = *this;
241 this->mTree = this->mTree->getNextChild();
242 return prev;
243 }
244
246 this->mTree = this->mTree->getNextChild();
247 return *this;
248 }
249
250 T* operator*() const { return mTree->getObject(); }
251
252 T* operator->() const { return mTree->getObject(); }
253
254private:
256};
257
258#endif /* JSULIST_H */
Definition JSUList.h:131
JSUListIterator< T > & operator=(JSULink< T > *link)
Definition JSUList.h:137
JSUListIterator(JSUList< T > *list)
Definition JSUList.h:135
JSUListIterator< T > operator++(int)
Definition JSUList.h:149
JSUListIterator< T > & operator++()
Definition JSUList.h:155
JSUListIterator(JSULink< T > *link)
Definition JSUList.h:134
JSUListIterator< T > operator--(int)
Definition JSUList.h:160
T * operator->() const
Definition JSUList.h:173
bool operator!=(JSUListIterator< T > const &other) const
Definition JSUList.h:147
JSUListIterator< T > & operator--()
Definition JSUList.h:166
bool operator!=(JSULink< T > const *other) const
Definition JSUList.h:145
T & operator*()
Definition JSUList.h:171
JSUListIterator()
Definition JSUList.h:133
bool operator==(JSULink< T > const *other) const
Definition JSUList.h:144
JSULink< T > * mLink
Definition JSUList.h:176
bool operator==(JSUListIterator< T > const &other) const
Definition JSUList.h:146
T * getObject() const
Definition JSUList.h:142
Definition JSUList.h:96
JSULink< T > * getEnd() const
Definition JSUList.h:121
bool insert(JSULink< T > *before, JSULink< T > *link)
Definition JSUList.h:109
bool remove(JSULink< T > *link)
Definition JSUList.h:113
bool append(JSULink< T > *link)
Definition JSUList.h:105
void initiate()
Definition JSUList.h:103
~JSUList()
Definition JSUList.h:101
JSUList(bool init)
Definition JSUList.h:99
u32 getNumLinks() const
Definition JSUList.h:123
JSULink< T > * getFirst() const
Definition JSUList.h:115
JSULink< T > * getLast() const
Definition JSUList.h:117
bool prepend(JSULink< T > *link)
Definition JSUList.h:107
JSUList()
Definition JSUList.h:98
JSULink< T > * getNth(u32 index) const
Definition JSUList.h:119
Definition JSUList.h:65
bool remove(JSUPtrLink *ptr)
Definition JSUList.cpp:120
JSUPtrLink * mTail
Definition JSUList.h:87
bool prepend(JSUPtrLink *ptr)
Definition JSUList.cpp:69
void setFirst(JSUPtrLink *first)
Definition JSUList.cpp:38
JSUPtrLink * getFirstLink() const
Definition JSUList.h:79
~JSUPtrList()
Definition JSUList.cpp:24
u32 mLength
Definition JSUList.h:88
bool append(JSUPtrLink *ptr)
Definition JSUList.cpp:47
JSUPtrLink * getNthLink(u32 i) const
Definition JSUList.cpp:144
JSUPtrLink * mHead
Definition JSUList.h:86
u32 getNumLinks() const
Definition JSUList.h:83
JSUPtrLink * getLastLink() const
Definition JSUList.h:81
void initiate()
Definition JSUList.cpp:32
JSUPtrList()
Definition JSUList.h:67
bool insert(JSUPtrLink *before, JSUPtrLink *ptr)
Definition JSUList.cpp:91
Definition JSUList.h:223
JSUTreeIterator(JSUTree< T > *tree)
Definition JSUList.h:226
T * operator->() const
Definition JSUList.h:252
JSUTree< T > * mTree
Definition JSUList.h:255
JSUTreeIterator()
Definition JSUList.h:225
JSUTreeIterator< T > & operator++()
Definition JSUList.h:245
T * operator*() const
Definition JSUList.h:250
JSUTreeIterator< T > & operator=(JSUTree< T > *tree)
Definition JSUList.h:228
T * getObject() const
Definition JSUList.h:233
bool operator!=(const JSUTree< T > *other) const
Definition JSUList.h:237
JSUTreeIterator< T > operator++(int)
Definition JSUList.h:239
bool operator==(const JSUTree< T > *other) const
Definition JSUList.h:235
Definition JSUList.h:188
JSUTree< T > * getPrevChild() const
Definition JSUList.h:209
bool prependChild(JSUTree< T > *child)
Definition JSUList.h:195
JSUTree< T > * getLastChild() const
Definition JSUList.h:205
T * getObject() const
Definition JSUList.h:213
bool removeChild(JSUTree< T > *child)
Definition JSUList.h:197
bool appendChild(JSUTree< T > *child)
Definition JSUList.h:193
bool insertChild(JSUTree< T > *before, JSUTree< T > *child)
Definition JSUList.h:199
JSUTree< T > * getNextChild() const
Definition JSUList.h:207
u32 getNumChildren() const
Definition JSUList.h:211
JSUTree< T > * getFirstChild() const
Definition JSUList.h:203
JSUTree< T > * getEndChild() const
Definition JSUList.h:201
~JSUTree()
Definition JSUList.h:191
JSUTree(T *owner)
Definition JSUList.h:190
JSUTree< T > * getParent() const
Definition JSUList.h:215
static e_rb_class * child[10]
Definition d_a_e_rb.cpp:505
static initFunc init[]
Definition d_menu_collect.cpp:39
DVDCommandBlock * prev
Definition dvdqueue.c:8
static u8 index[20][3]
Definition GXDraw.c:434
int i
Definition e_log.c:92
unsigned long u32
Definition types.h:12