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*>(getObjectPtr()); }
49
50 JSUList<T>* getSupervisor() const { return static_cast<JSUList<T>*>(this->getList()); }
51
52 JSULink<T>* getNext() const { return static_cast<JSULink*>(this->JSUPtrLink::getNext()); }
53
54 JSULink<T>* getPrev() const { return static_cast<JSULink*>(this->JSUPtrLink::getPrev()); }
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);
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
85private:
89};
90
95template <typename T>
96class JSUList : public JSUPtrList {
97public:
100
102
103 bool append(JSULink<T>* link) { return this->JSUPtrList::append((JSUPtrLink*)link); }
104
105 bool prepend(JSULink<T>* link) { return this->JSUPtrList::prepend((JSUPtrLink*)link); }
106
108 return this->JSUPtrList::insert((JSUPtrLink*)before, (JSUPtrLink*)link);
109 }
110
111 bool remove(JSULink<T>* link) { return this->JSUPtrList::remove((JSUPtrLink*)link); }
112
114
115 JSULink<T>* getLast() const { return (JSULink<T>*)getLastLink(); }
116
117 JSULink<T>* getNth(int index) { return (JSULink<T>*)getNthLink(index); }
118
119 JSULink<T>* getEnd() const { return NULL; }
120
121 u32 getNumLinks() const { return this->JSUPtrList::getNumLinks(); }
122};
123
128template <typename T>
130public:
134
136 this->mLink = link;
137 return *this;
138 }
139
140 T* getObject() { return this->mLink->getObject(); }
141
142 bool operator==(JSULink<T> const* other) const { return this->mLink == other; }
143 bool operator!=(JSULink<T> const* other) const { return this->mLink != other; }
144 bool operator==(JSUListIterator<T> const& other) const { return this->mLink == other.mLink; }
145 bool operator!=(JSUListIterator<T> const& other) const { return this->mLink != other.mLink; }
146
148 JSUListIterator<T> prev = *this;
149 this->mLink = this->mLink->getNext();
150 return prev;
151 }
152
154 this->mLink = this->mLink->getNext();
155 return *this;
156 }
157
159 JSUListIterator<T> prev = *this;
160 this->mLink = this->mLink->getPrev();
161 return prev;
162 }
163
165 this->mLink = this->mLink->getPrev();
166 return *this;
167 }
168
169 T& operator*() { return *this->getObject(); }
170
171 T* operator->() { return this->getObject(); }
172
173// private:
175};
176
177//
178// Tree
179//
180
185template <typename T>
186class JSUTree : public JSUList<T>, public JSULink<T> {
187public:
188 JSUTree(T* owner) : JSUList<T>(), JSULink<T>(owner) {}
190
191 bool appendChild(JSUTree<T>* child) { return this->append(child); }
192
193 bool removeChild(JSUTree<T>* child) { return this->remove(child); }
194
195 bool insertChild(JSUTree<T>* before, JSUTree<T>* child) { return this->insert(before, child); }
196
197 JSUTree<T>* getEndChild() const { return NULL; }
198
199 JSUTree<T>* getFirstChild() const { return (JSUTree<T>*)this->getFirst(); }
200
201 JSUTree<T>* getLastChild() const { return (JSUTree<T>*)this->getLast(); }
202
203 JSUTree<T>* getNextChild() const { return (JSUTree<T>*)this->getNext(); }
204
205 JSUTree<T>* getPrevChild() const { return (JSUTree<T>*)this->getPrev(); }
206
207 u32 getNumChildren() const { return this->getNumLinks(); }
208
209 T* getObject() const { return (T*)this->getObjectPtr(); }
210
211 JSUTree<T>* getParent() const { return (JSUTree<T>*)this->getList(); }
212};
213
218template <typename T>
220public:
223
225 this->mTree = tree;
226 return *this;
227 }
228
229 T* getObject() { return this->mTree->getObject(); }
230
231 bool operator==(JSUTree<T>* other) { return this->mTree == other; }
232
233 bool operator!=(JSUTree<T>* other) { return this->mTree != other; }
234
236 JSUTreeIterator<T> prev = *this;
237 this->mTree = this->mTree->getNextChild();
238 return prev;
239 }
240
242 this->mTree = this->mTree->getNextChild();
243 return *this;
244 }
245
246 T* operator*() { return this->getObject(); }
247
248 T* operator->() { return this->getObject(); }
249
250private:
252};
253
254#endif /* JSULIST_H */
T cLib_calcTimer(T *value)
Definition c_lib.h:74
Definition JSUList.h:129
JSUListIterator< T > & operator=(JSULink< T > *link)
Definition JSUList.h:135
JSUListIterator(JSUList< T > *list)
Definition JSUList.h:133
JSUListIterator< T > operator++(int)
Definition JSUList.h:147
JSUListIterator< T > & operator++()
Definition JSUList.h:153
JSUListIterator(JSULink< T > *link)
Definition JSUList.h:132
JSUListIterator< T > operator--(int)
Definition JSUList.h:158
bool operator!=(JSUListIterator< T > const &other) const
Definition JSUList.h:145
JSUListIterator< T > & operator--()
Definition JSUList.h:164
T * operator->()
Definition JSUList.h:171
bool operator!=(JSULink< T > const *other) const
Definition JSUList.h:143
T * getObject()
Definition JSUList.h:140
T & operator*()
Definition JSUList.h:169
JSUListIterator()
Definition JSUList.h:131
bool operator==(JSULink< T > const *other) const
Definition JSUList.h:142
JSULink< T > * mLink
Definition JSUList.h:174
bool operator==(JSUListIterator< T > const &other) const
Definition JSUList.h:144
Definition JSUList.h:96
JSULink< T > * getEnd() const
Definition JSUList.h:119
bool insert(JSULink< T > *before, JSULink< T > *link)
Definition JSUList.h:107
bool remove(JSULink< T > *link)
Definition JSUList.h:111
JSULink< T > * getNth(int index)
Definition JSUList.h:117
bool append(JSULink< T > *link)
Definition JSUList.h:103
~JSUList()
Definition JSUList.h:101
JSUList(bool init)
Definition JSUList.h:99
u32 getNumLinks() const
Definition JSUList.h:121
JSULink< T > * getFirst() const
Definition JSUList.h:113
JSULink< T > * getLast() const
Definition JSUList.h:115
bool prepend(JSULink< T > *link)
Definition JSUList.h:105
JSUList()
Definition JSUList.h:98
Definition JSUList.h:65
bool remove(JSUPtrLink *ptr)
Definition JSUList.cpp:127
JSUPtrLink * mTail
Definition JSUList.h:87
bool prepend(JSUPtrLink *ptr)
Definition JSUList.cpp:75
void setFirst(JSUPtrLink *first)
Definition JSUList.cpp:43
JSUPtrLink * getFirstLink() const
Definition JSUList.h:79
~JSUPtrList()
Definition JSUList.cpp:27
u32 mLength
Definition JSUList.h:88
bool append(JSUPtrLink *ptr)
Definition JSUList.cpp:52
JSUPtrLink * getNthLink(u32 i) const
Definition JSUList.cpp:151
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:37
JSUPtrList()
Definition JSUList.h:67
bool insert(JSUPtrLink *before, JSUPtrLink *ptr)
Definition JSUList.cpp:98
Definition JSUList.h:219
JSUTreeIterator(JSUTree< T > *tree)
Definition JSUList.h:222
JSUTree< T > * mTree
Definition JSUList.h:251
JSUTreeIterator()
Definition JSUList.h:221
T * operator->()
Definition JSUList.h:248
bool operator!=(JSUTree< T > *other)
Definition JSUList.h:233
JSUTreeIterator< T > & operator++()
Definition JSUList.h:241
T * getObject()
Definition JSUList.h:229
JSUTreeIterator< T > & operator=(JSUTree< T > *tree)
Definition JSUList.h:224
T * operator*()
Definition JSUList.h:246
JSUTreeIterator< T > operator++(int)
Definition JSUList.h:235
bool operator==(JSUTree< T > *other)
Definition JSUList.h:231
Definition JSUList.h:186
JSUTree< T > * getPrevChild() const
Definition JSUList.h:205
JSUTree< T > * getLastChild() const
Definition JSUList.h:201
T * getObject() const
Definition JSUList.h:209
bool removeChild(JSUTree< T > *child)
Definition JSUList.h:193
bool appendChild(JSUTree< T > *child)
Definition JSUList.h:191
bool insertChild(JSUTree< T > *before, JSUTree< T > *child)
Definition JSUList.h:195
JSUTree< T > * getNextChild() const
Definition JSUList.h:203
u32 getNumChildren() const
Definition JSUList.h:207
JSUTree< T > * getFirstChild() const
Definition JSUList.h:199
JSUTree< T > * getEndChild() const
Definition JSUList.h:197
~JSUTree()
Definition JSUList.h:189
JSUTree(T *owner)
Definition JSUList.h:188
JSUTree< T > * getParent() const
Definition JSUList.h:211
static u8 child[40]
Definition d_a_e_rb.cpp:675
static initFunc init[]
Definition d_menu_collect.cpp:42
int i
Definition e_pow.c:165
static const double T[]
Definition k_tan.c:106
unsigned long u32
Definition types.h:10