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
25 iterator& operator++() { node = node->getNext(); return *this; }
26 iterator& operator--() { node = node->getPrev(); return *this; }
27 iterator operator++(int) { const iterator old(*this); (void)++*this; return old; }
28 iterator operator--(int) { const iterator old(*this); (void)--*this; return old; }
29 friend bool operator==(iterator a, iterator b) { return a.node == b.node; }
30 friend bool operator!=(iterator a, iterator b) { return !(a == b); }
31
32 TLinkListNode* operator->() const { return node; }
33 TLinkListNode& operator*() const { return *node; }
34
35 public:
36 /* 0x00 */ TLinkListNode* node;
37 };
38
41 explicit const_iterator(iterator it) { node = it.node; }
42
43 const_iterator& operator++() { node = node->getNext(); return *this; }
44 const_iterator& operator--() { node = node->getPrev(); return *this; }
45 const_iterator operator++(int) { const const_iterator old(*this); (void)++*this; return old; }
46 const_iterator operator--(int) { const const_iterator old(*this); (void)--*this; return old; }
47 friend bool operator==(const_iterator a, const_iterator b) { return a.node == b.node; }
48 friend bool operator!=(const_iterator a, const_iterator b) { return !(a == b); }
49
50 friend bool operator==(const_iterator a, iterator b) { return a.node == b.node; }
51 friend bool operator!=(const_iterator a, iterator b) { return !(a == b); }
52
53 const TLinkListNode* operator->() const { return node; }
54 const TLinkListNode& operator*() const { return *node; }
55
56 public:
57 /* 0x00 */ TLinkListNode* node;
58 };
59
62
63 void Initialize_() {
64 count = 0;
67 }
68
73 u32 size() { return count; }
74 bool empty() { return size() == 0; }
75 iterator pop_front() { return erase(begin()); }
76
85
86 bool Iterator_isEnd_(const_iterator it) const { return it.node == &ocObject_; }
87 template <typename Predicate>
89 iterator it = begin();
90
92 if (predicate(*it)) {
94 ++it;
95 tList.splice(tList.end(), *this, itPrev);
96 } else {
97 ++it;
98 }
99 }
100 }
101
102 template <typename Predicate>
107
108public:
109 /* 0x00 */ u32 count;
111}; // Size: 0xC
112
113template <typename T, int I>
114struct TLinkList : public TNodeLinkList {
116
117 struct iterator {
119
121 ++base;
122 return *this;
123 }
125 --base;
126 return *this;
127 }
129 const iterator old(*this);
130 ++*this;
131 return old;
132 }
134 const iterator old(*this);
135 --*this;
136 return old;
137 }
138 friend bool operator==(iterator a, iterator b) { return a.base == b.base; }
139 friend bool operator!=(iterator a, iterator b) { return !(a == b); }
140
141 T* operator->() const { return Element_toValue(base.operator->()); }
142 T& operator*() const { return *operator->(); }
143
144 public:
146 };
147
151
153 ++base;
154 return *this;
155 }
157 --base;
158 return *this;
159 }
161 const const_iterator old(*this);
162 ++*this;
163 return old;
164 }
166 const const_iterator old(*this);
167 --*this;
168 return old;
169 }
170 friend bool operator==(const_iterator a, const_iterator b) { return a.base == b.base; }
171 friend bool operator!=(const_iterator a, const_iterator b) { return !(a == b); }
172
173 const T* operator->() const { return Element_toValue(base.operator->()); }
174 const T& operator*() const { return *operator->(); }
175
176 public:
178 };
179
180 static const TLinkListNode* Element_toNode(const T* element) {
181 (void)element; // Debug-only assert
182 return reinterpret_cast<const TLinkListNode*>(reinterpret_cast<const char*>(element) - I);
183 }
185 (void)element; // Debug-only assert
186 return reinterpret_cast<TLinkListNode*>(reinterpret_cast<char*>(element) - I);
187 }
188 static const T* Element_toValue(const TLinkListNode* node) {
189 (void)node; // Debug-only assert
190 return reinterpret_cast<const T*>(reinterpret_cast<const char*>(node) + I);
191 }
193 (void)node; // Debug-only assert
194 return reinterpret_cast<T*>(reinterpret_cast<char*>(node) + I);
195 }
196
201
203 const_iterator begin() const { return const_iterator(const_cast<TLinkList*>(this)->begin()); }
205 const_iterator end() const { return const_iterator(const_cast<TLinkList*>(this)->end()); }
206 T& front() { return *begin(); }
207 T& back() { return *--end(); }
215};
216
217template <typename T, int I>
218struct TLinkList_factory : public TLinkList<T, I> {
220 virtual T* Do_create() = 0;
221 virtual void Do_destroy(T*) = 0;
223 while (!this->empty()) {
224 T* item = &this->front();
225 this->pop_front();
226 Do_destroy(item);
227 }
228 }
229};
230
231template <typename T>
235
236 bool isEnd() const { return current != end; }
237 operator bool() const { return isEnd(); }
239 T rv = current;
240 ++current;
241 return rv;
242 }
243
246};
247
248// TEnumerator2 should be the same but there are two issues:
249// 1. How to derive the iterator return type for operator* (the debug makes it seem like operator* is called
250// so the return value should be what the iterator points to)
251// 2. Calling the * operator seems to make functions using TEnumerator<T*> not work. See
252// JStudio::TAdaptor::adaptor_setVariableValue_n
253// Perhaps template specialization?
254template <typename Iterator, typename T>
258
259 bool isEnd() const { return current != end; }
260 operator bool() const { return isEnd(); }
262 T& rv = *current;
263 ++current;
264 return rv;
265 }
266
269};
270
271template <typename T, int I>
272struct TContainerEnumerator : public TEnumerator2<typename TLinkList<T, I>::iterator, T> {
275};
276
277
278template <typename T, int I>
279struct TContainerEnumerator_const : public TEnumerator2<typename TLinkList<T, I>::const_iterator, const T> {
281 : TEnumerator2<typename TLinkList<T, I>::const_iterator, const T>(param_0->begin(), param_0->end()) {}
282};
283
284}; // namespace JGadget
285
286#endif /* LINKLIST_H */
T cLib_calcTimer(T *value)
Definition c_lib.h:79
a
Definition k_cos.c:89
static const double T[]
Definition k_tan.c:106
Definition functionvalue.cpp:19
Definition linklist.h:279
TContainerEnumerator_const(const TLinkList< T, I > *param_0)
Definition linklist.h:280
Definition linklist.h:272
TContainerEnumerator(TLinkList< T, I > *param_0)
Definition linklist.h:273
Definition linklist.h:255
TEnumerator2(Iterator _current, Iterator _end)
Definition linklist.h:256
Iterator end
Definition linklist.h:268
bool isEnd() const
Definition linklist.h:259
T & operator*()
Definition linklist.h:261
Iterator current
Definition linklist.h:267
Definition linklist.h:232
TEnumerator(T _current, T _end)
Definition linklist.h:233
T operator*()
Definition linklist.h:238
T end
Definition linklist.h:245
bool isEnd() const
Definition linklist.h:236
T current
Definition linklist.h:244
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