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
7#include <iterator.h>
8
9
10namespace JGadget {
13 mNext = NULL;
14 mPrev = NULL;
15 }
16
18
19 TLinkListNode* getNext() const { return mNext; }
20 TLinkListNode* getPrev() const { return mPrev; }
21
22public:
23 /* 0x0 */ TLinkListNode* mNext;
24 /* 0x4 */ TLinkListNode* mPrev;
25}; // Size: 0x8
26
28 struct iterator {
29 iterator() { node = NULL; }
30 explicit iterator(TLinkListNode* pNode) { node = pNode; }
31 iterator& operator=(const iterator& other) { node = other.node; return *this; }
32
33 iterator& operator++() { node = node->getNext(); return *this; }
34 iterator& operator--() { node = node->getPrev(); return *this; }
35 iterator operator++(int) { const iterator old(*this); (void)++*this; return old; }
36 iterator operator--(int) { const iterator old(*this); (void)--*this; return old; }
37 friend bool operator==(iterator a, iterator b) { return a.node == b.node; }
38 friend bool operator!=(iterator a, iterator b) { return !(a == b); }
39
40 TLinkListNode* operator->() const { return node; }
41 TLinkListNode& operator*() const { return *node; }
42
43 public:
44 /* 0x00 */ TLinkListNode* node;
45 };
46
48 explicit const_iterator(TLinkListNode* pNode) { node = pNode; }
49 explicit const_iterator(iterator it) { node = it.node; }
50
51 const_iterator& operator++() { node = node->getNext(); return *this; }
52 const_iterator& operator--() { node = node->getPrev(); return *this; }
53 const_iterator operator++(int) { const const_iterator old(*this); (void)++*this; return old; }
54 const_iterator operator--(int) { const const_iterator old(*this); (void)--*this; return old; }
55 friend bool operator==(const_iterator a, const_iterator b) { return a.node == b.node; }
56 friend bool operator!=(const_iterator a, const_iterator b) { return !(a == b); }
57
58 friend bool operator==(const_iterator a, iterator b) { return a.node == b.node; }
59 friend bool operator!=(const_iterator a, iterator b) { return !(a == b); }
60
61 const TLinkListNode* operator->() const { return node; }
62 const TLinkListNode& operator*() const { return *node; }
63
64 public:
65 /* 0x00 */ TLinkListNode* node;
66 };
67
70
71 void Initialize_() {
72 count = 0;
75 }
76
81 u32 size() const { return count; }
82 bool empty() const { return size() == 0; }
83 iterator pop_front() { return erase(begin()); }
84
93
94 bool Iterator_isEnd_(const_iterator it) const { return it.node == &ocObject_; }
95 template <typename Predicate>
96 void Remove_if(Predicate predicate, TNodeLinkList& tList) {
97 iterator it = begin();
98
99 while (!Iterator_isEnd_(const_iterator(it))) {
100 if (predicate(*it)) {
101 iterator itPrev = it;
102 ++it;
103 tList.splice(tList.end(), *this, itPrev);
104 } else {
105 ++it;
106 }
107 }
108 }
109
110 template <typename Predicate>
111 void remove_if(Predicate predicate) {
112 TNodeLinkList list;
113 Remove_if(predicate, list);
114 }
115
116public:
117 /* 0x00 */ u32 count;
119}; // Size: 0xC
120
121template <typename T, int I>
124
128
130 //TODO: Probably fakematch? Not sure what's going on here exactly
133 this->node = rhs.node;
134 return *this;
135 }
136
139 return *this;
140 }
143 return *this;
144 }
146 const iterator old(*this);
147 ++*this;
148 return old;
149 }
151 const iterator old(*this);
152 --*this;
153 return old;
154 }
155 friend bool operator==(iterator a, iterator b) {
157 }
158 friend bool operator!=(iterator a, iterator b) { return !(a == b); }
159
160 T* operator->() const { return Element_toValue(TNodeLinkList::iterator::operator->()); }
161 T& operator*() const {
162 T* p = operator->();
163 JUT_ASSERT(541, p!=NULL);
164 return *p;
165 }
166
168 typedef T value_type;
169 typedef T* pointer;
170 typedef T& reference;
172 };
173
179
189 const const_iterator old(*this);
190 ++*this;
191 return old;
192 }
194 const const_iterator old(*this);
195 --*this;
196 return old;
197 }
201 friend bool operator!=(const_iterator a, const_iterator b) { return !(a == b); }
202
203 const T* operator->() const { return Element_toValue(TNodeLinkList::const_iterator::operator->()); }
204 const T& operator*() const {
205 const T* p = &*operator->();
206 JUT_ASSERT(0x24a, p!=NULL);
207 return *p;
208 }
209 };
210
212 JUT_ASSERT(0x2F1, p!=NULL);
213 return reinterpret_cast<TLinkListNode*>(reinterpret_cast<char*>(p) - I);
214 }
215 static const TLinkListNode* Element_toNode(const T* p) {
216 JUT_ASSERT(0x2F6, p!=NULL);
217 return reinterpret_cast<const TLinkListNode*>(reinterpret_cast<const char*>(p) - I);
218 }
220 JUT_ASSERT(0x2FB, p!=NULL);
221 return reinterpret_cast<T*>(reinterpret_cast<char*>(p) + I);
222 }
223 static const T* Element_toValue(const TLinkListNode* p) {
224 JUT_ASSERT(0x300, p!=NULL);
225 return reinterpret_cast<const T*>(reinterpret_cast<const char*>(p) + I);
226 }
227
228 iterator Insert(iterator iter, T* element) {
230 }
231 iterator Erase(T* element) { return iterator(TNodeLinkList::Erase(Element_toNode(element))); }
232
234 const_iterator begin() const { return const_iterator(const_cast<TLinkList*>(this)->begin()); }
236 const_iterator end() const { return const_iterator(const_cast<TLinkList*>(this)->end()); }
237 T& front() { return *begin(); }
238 T& back() { JUT_ASSERT(652, !empty()); return *--end(); }
240 void Push_front(T* element) { Insert(begin(), element); }
241 void Push_back(T* element) { Insert(end(), element); }
242 iterator Find(const T* element) {
244 }
245 void Remove(T* element) { TNodeLinkList::Remove(Element_toNode(element)); }
246
247 typedef T value_type;
248};
249
250template <typename T, int I>
251struct TLinkList_factory : public TLinkList<T, I> {
252 inline virtual ~TLinkList_factory() = 0;
253 virtual T* Do_create() = 0;
254 virtual void Do_destroy(T*) = 0;
255
257 while (!this->empty()) {
258 T* item = &this->front();
259 this->pop_front();
260 Do_destroy(item);
261 }
262 }
263
265 typename TLinkList<T, I>::iterator spC(Erase(param_0));
266 Do_destroy(param_0);
267 return spC;
268 }
269};
270
271template <typename T, int I>
273 JGADGET_ASSERTWARN(934, empty());
274}
275
276template <typename T>
278 inline TEnumerator(T _current, T _end)
279 : current(_current), end(_end) {}
280
281 bool isEnd() const { return current != end; }
282 operator bool() const { return isEnd(); }
284 T rv = current;
285 ++current;
286 return rv;
287 }
288
291};
292
293// TEnumerator2 should be the same but there are two issues:
294// 1. How to derive the iterator return type for operator* (the debug makes it seem like operator* is called
295// so the return value should be what the iterator points to)
296// 2. Calling the * operator seems to make functions using TEnumerator<T*> not work. See
297// JStudio::TAdaptor::adaptor_setVariableValue_n
298// Perhaps template specialization?
299template <typename Iterator, typename T>
301 inline TEnumerator2(Iterator _current, Iterator _end)
302 : current(_current), end(_end) {}
303
304 bool isEnd() const { return current != end; }
305 operator bool() const { return isEnd(); }
307 T& rv = *current;
308 ++current;
309 return rv;
310 }
311
312 Iterator current;
313 Iterator end;
314};
315
316template <typename T>
317struct TContainerEnumerator : public TEnumerator2<typename T::iterator, typename T::value_type> {
318 inline TContainerEnumerator(T& param_0)
319 : TEnumerator2<typename T::iterator, typename T::value_type>(param_0.begin(), param_0.end()) {}
320};
321
322
323template <typename T, int I>
324struct TContainerEnumerator_const : public TEnumerator2<typename TLinkList<T, I>::const_iterator, const T> {
326 : TEnumerator2<typename TLinkList<T, I>::const_iterator, const T>(param_0->begin(), param_0->end()) {}
327};
328
329}; // namespace JGadget
330
331#endif /* LINKLIST_H */
unsigned long u32
Definition types.h:12
signed long s32
Definition types.h:11
p
Definition e_acos.c:98
a
Definition k_cos.c:89
Definition binary.h:8
Definition linklist.h:324
TContainerEnumerator_const(const TLinkList< T, I > *param_0)
Definition linklist.h:325
Definition linklist.h:317
TContainerEnumerator(T &param_0)
Definition linklist.h:318
Definition linklist.h:300
TEnumerator2(Iterator _current, Iterator _end)
Definition linklist.h:301
Iterator end
Definition linklist.h:313
bool isEnd() const
Definition linklist.h:304
T & operator*()
Definition linklist.h:306
Iterator current
Definition linklist.h:312
Definition linklist.h:277
TEnumerator(T _current, T _end)
Definition linklist.h:278
T operator*()
Definition linklist.h:283
T end
Definition linklist.h:290
bool isEnd() const
Definition linklist.h:281
T current
Definition linklist.h:289
Definition search.h:38
Definition linklist.h:11
TLinkListNode * mNext
Definition linklist.h:23
TLinkListNode * getPrev() const
Definition linklist.h:20
TLinkListNode * mPrev
Definition linklist.h:24
~TLinkListNode()
Definition linklist.h:17
TLinkListNode * getNext() const
Definition linklist.h:19
TLinkListNode()
Definition linklist.h:12
Definition iterator.h:10