Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
Loading...
Searching...
No Matches
linklist.h
Go to the documentation of this file.
1#ifndef LINKLIST_H
2#define LINKLIST_H
3
4#include "dolphin/types.h"
5
6namespace JGadget {
9 mNext = NULL;
10 mPrev = NULL;
11 }
12
13 TLinkListNode* getNext() const { return mNext; }
14 TLinkListNode* getPrev() const { return mPrev; }
15
16public:
17 /* 0x0 */ TLinkListNode* mNext;
18 /* 0x4 */ TLinkListNode* mPrev;
19}; // Size: 0x8
20
22 struct iterator {
24
26 node = node->getNext();
27 return *this;
28 }
30 node = node->getPrev();
31 return *this;
32 }
34 const iterator old(*this);
35 (void)++*this;
36 return old;
37 }
39 const iterator old(*this);
40 (void)--*this;
41 return old;
42 }
43 friend bool operator==(iterator a, iterator b) { return a.node == b.node; }
44 friend bool operator!=(iterator a, iterator b) { return !(a == b); }
45
46 TLinkListNode* operator->() const { return node; }
47 TLinkListNode& operator*() const { return *node; }
48
49 public:
50 /* 0x00 */ TLinkListNode* node;
51 };
52
56 explicit const_iterator(iterator it) { node = it.node; }
57
59 node = node->getNext();
60 return *this;
61 }
63 node = node->getPrev();
64 return *this;
65 }
67 const const_iterator old(*this);
68 (void)++*this;
69 return old;
70 }
72 const const_iterator old(*this);
73 (void)--*this;
74 return old;
75 }
76 friend bool operator==(const_iterator a, const_iterator b) { return a.node == b.node; }
77 friend bool operator!=(const_iterator a, const_iterator b) { return !(a == b); }
78
79 friend bool operator==(const_iterator a, iterator b) { return a.node == b.node; }
80 friend bool operator!=(const_iterator a, iterator b) { return !(a == b); }
81
82 const TLinkListNode* operator->() const { return node; }
83 const TLinkListNode& operator*() const { return *node; }
84
85 public:
86 /* 0x00 */ TLinkListNode* node;
87 };
88
91
92 void Initialize_() {
93 count = 0;
96 }
97
102 u32 size() { return count; }
103 bool empty() { return size() == 0; }
104 iterator pop_front() { return erase(begin()); }
105
114
115 bool Iterator_isEnd_(const_iterator it) const { return it.node == &ocObject_; }
116 template <typename Predicate>
118 iterator it = begin();
119
121 if (predicate(*it)) {
123 ++it;
124 tList.splice(tList.end(), *this, itPrev);
125 } else {
126 ++it;
127 }
128 }
129 }
130
131 template <typename Predicate>
136
137public:
138 /* 0x00 */ u32 count;
140}; // Size: 0xC
141
142template <typename T, int I>
143struct TLinkList : public TNodeLinkList {
145
146 struct iterator {
148
150 ++base;
151 return *this;
152 }
154 --base;
155 return *this;
156 }
158 const iterator old(*this);
159 ++*this;
160 return old;
161 }
163 const iterator old(*this);
164 --*this;
165 return old;
166 }
167 friend bool operator==(iterator a, iterator b) { return a.base == b.base; }
168 friend bool operator!=(iterator a, iterator b) { return !(a == b); }
169
170 T* operator->() const { return Element_toValue(base.operator->()); }
171 T& operator*() const { return *operator->(); }
172
173 public:
175 };
176
180
182 ++base;
183 return *this;
184 }
186 --base;
187 return *this;
188 }
190 const const_iterator old(*this);
191 ++*this;
192 return old;
193 }
195 const const_iterator old(*this);
196 --*this;
197 return old;
198 }
199 friend bool operator==(const_iterator a, const_iterator b) { return a.base == b.base; }
200 friend bool operator!=(const_iterator a, const_iterator b) { return !(a == b); }
201
202 const T* operator->() const { return Element_toValue(base.operator->()); }
203 const T& operator*() const { return *operator->(); }
204
205 public:
207 };
208
209 static const TLinkListNode* Element_toNode(const T* element) {
210 (void)element; // Debug-only assert
211 return reinterpret_cast<const TLinkListNode*>(reinterpret_cast<const char*>(element) - I);
212 }
214 (void)element; // Debug-only assert
215 return reinterpret_cast<TLinkListNode*>(reinterpret_cast<char*>(element) - I);
216 }
217 static const T* Element_toValue(const TLinkListNode* node) {
218 (void)node; // Debug-only assert
219 return reinterpret_cast<const T*>(reinterpret_cast<const char*>(node) + I);
220 }
222 (void)node; // Debug-only assert
223 return reinterpret_cast<T*>(reinterpret_cast<char*>(node) + I);
224 }
225
230
232 const_iterator begin() const { return const_iterator(const_cast<TLinkList*>(this)->begin()); }
234 const_iterator end() const { return const_iterator(const_cast<TLinkList*>(this)->end()); }
235 T& front() { return *begin(); }
236 T& back() { return *--end(); }
244};
245
246template <typename T, int I>
247struct TLinkList_factory : public TLinkList<T, I> {
249 virtual T* Do_create() = 0;
250 virtual void Do_destroy(T*) = 0;
252 while (!this->empty()) {
253 T* item = &this->front();
254 this->pop_front();
255 Do_destroy(item);
256 }
257 }
258};
259
260template <typename T>
264
265 bool isEnd() const { return current != end; }
266 operator bool() const { return isEnd(); }
268 T rv = current;
269 ++current;
270 return rv;
271 }
272
275};
276
277// TEnumerator2 should be the same but there are two issues:
278// 1. How to derive the iterator return type for operator* (the debug makes it seem like operator* is called
279// so the return value should be what the iterator points to)
280// 2. Calling the * operator seems to make functions using TEnumerator<T*> not work. See
281// JStudio::TAdaptor::adaptor_setVariableValue_n
282// Perhaps template specialization?
283template <typename Iterator, typename T>
287
288 bool isEnd() const { return current != end; }
289 operator bool() const { return isEnd(); }
291 T& rv = *current;
292 ++current;
293 return rv;
294 }
295
298};
299
300template <typename T, int I>
301struct TContainerEnumerator : public TEnumerator2<typename TLinkList<T, I>::iterator, T> {
304};
305
306
307template <typename T, int I>
308struct TContainerEnumerator_const : public TEnumerator2<typename TLinkList<T, I>::const_iterator, const T> {
310 : TEnumerator2<typename TLinkList<T, I>::const_iterator, const T>(param_0->begin(), param_0->end()) {}
311};
312
313}; // namespace JGadget
314
315#endif /* LINKLIST_H */
T cLib_calcTimer(T *value)
Definition c_lib.h:74
a
Definition k_cos.c:89
static const double T[]
Definition k_tan.c:106
Definition std-vector.cpp:14
Definition linklist.h:308
TContainerEnumerator_const(const TLinkList< T, I > *param_0)
Definition linklist.h:309
Definition linklist.h:301
TContainerEnumerator(TLinkList< T, I > *param_0)
Definition linklist.h:302
Definition linklist.h:284
TEnumerator2(Iterator _current, Iterator _end)
Definition linklist.h:285
Iterator end
Definition linklist.h:297
bool isEnd() const
Definition linklist.h:288
T & operator*()
Definition linklist.h:290
Iterator current
Definition linklist.h:296
Definition linklist.h:261
TEnumerator(T _current, T _end)
Definition linklist.h:262
T operator*()
Definition linklist.h:267
T end
Definition linklist.h:274
bool isEnd() const
Definition linklist.h:265
T current
Definition linklist.h:273
Definition linklist.h:7
TLinkListNode * mNext
Definition linklist.h:17
TLinkListNode * getPrev() const
Definition linklist.h:14
TLinkListNode * mPrev
Definition linklist.h:18
TLinkListNode * getNext() const
Definition linklist.h:13
TLinkListNode()
Definition linklist.h:8
unsigned long u32
Definition types.h:10