Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
Loading...
Searching...
No Matches
std-vector.h
Go to the documentation of this file.
1#ifndef STD_VECTOR_H
2#define STD_VECTOR_H
3
5#include "algorithm.h"
6#include "msl_memory.h"
7
8namespace JGadget {
9namespace vector {
10/* 802DCCC8 */ u32 extend_default(u32, u32, u32);
11};
12
13typedef u32 (*extendFunc)(u32, u32, u32);
14
15template <typename T, typename Allocator = JGadget::TAllocator<T> >
16struct TVector {
30
38
40 clear();
41 mAllocator.deallocate(pBegin_, 0);
42 }
43
44 T* insert(T* pos, const T& val) {
45 u32 diff = (int)((u32)pos - (u32)begin()) / 4;
46 insert(pos, 1, val);
47 return pBegin_ + diff;
48 }
49
50 void insert(T* pos, u32 count, const T& val) {
51 if (count != 0) {
52 T* ptr = Insert_raw(pos, count);
53 if (ptr == end()) {
54 /* JGadget_outMessage sp120(JGadget_outMessage::warning, __FILE__, 0x141);
55 sp120 << "can't allocate memory"; */
56 } else {
57 std::uninitialized_fill_n(ptr, count, val);
58 }
59 }
60 }
61
63 JUT_ASSERT(446, (pBegin_ <= pIt) && (pIt <= pEnd_));
64
65 T* const pFirst = pIt;
66
67 if (pCount == 0) {
68 return pIt;
69 }
70
71 if (pCount + size() <= mCapacity) {
72 void** newEnd = pFirst + pCount;
73
74 if (newEnd < pEnd_) {
79
80 pEnd_ += pCount;
81 return pIt;
82 } else {
85
86 pEnd_ += pCount;
87 return pIt;
88 }
89 }
90
92
93 void** newDataPointer = mAllocator.allocate(newSize, 0);
94 if (!newDataPointer) {
95 return end();
96 }
97
99
102
105
109
110 return endOfCopy;
111 }
112
113 T* begin() { return pBegin_; }
114
115 T* end() { return pEnd_; }
116
118 if (pBegin_ == 0) {
119 return 0;
120 }
121 return (int)((u32)pEnd_ - (u32)pBegin_) / 4;
122 }
123
124 u32 capacity() { return mCapacity; }
125
127 JUT_ASSERT(0x22B, pfnExtend_!=0);
128
129 u32 oldSize = size();
130 u32 neededNewSpace = oldSize + count;
132
134 }
135
137 for (; start != end; start++) {
138 mAllocator.destroy(start);
139 }
140 }
141
143
145 T* vectorEnd = pEnd_;
148 pEnd_ = ppvVar3;
149 return start;
150 }
151
152 void clear() { erase(begin(), end()); }
153
155 /* 0x04 */ T* pBegin_;
156 /* 0x08 */ T* pEnd_;
157 /* 0x0C */ u32 mCapacity;
159};
160
161struct TVector_pointer_void : public TVector<void*, TAllocator<void*> > {
165
167
168 void insert(void**, void* const&);
169 void** erase(void**, void**);
170
171 void clear() { erase(begin(), end()); }
172 void push_back(const void*& value) { insert(end(), (void* const&)value); }
173};
174} // namespace JGadget
175
176#endif /* STD_VECTOR_H */
T cLib_calcTimer(T *value)
Definition c_lib.h:79
static u8 pos[12]
Definition d_a_obj_kago.cpp:839
static const double T[]
Definition k_tan.c:106
u32 extend_default(u32, u32, u32)
Definition std-vector.cpp:9
Definition functionvalue.cpp:19
u32(* extendFunc)(u32, u32, u32)
Definition std-vector.h:13
T * uninitialized_copy(T *first, T *last, T *result)
Definition msl_memory.h:45
OutputIt copy(InputIt first, InputIt last, OutputIt d_first)
Definition algorithm.h:69
BidirectionalIterator2 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last, BidirectionalIterator2 result)
Definition algorithm.h:78
ForwardIt uninitialized_fill_n(ForwardIt first, Size count, const T &value)
Definition msl_memory.h:7
@ start
Definition strtoul.c:8
Definition std-memory.h:8
Allocator * mAllocator
Definition std-vector.h:27
T * mPtr
Definition std-vector.h:28
TDestructed_deallocate_(JGadget::TAllocator< T > &allocator, T *ptr)
Definition std-vector.h:18
void set(T *ptr)
Definition std-vector.h:25
~TDestructed_deallocate_()
Definition std-vector.h:23
Definition std-vector.h:161
void insert(void **, void *const &)
Definition std-vector.cpp:24
void ** erase(void **, void **)
Definition std-vector.cpp:30
void push_back(const void *&value)
Definition std-vector.h:172
void clear()
Definition std-vector.h:171
TVector_pointer_void(u32, void *const &, const JGadget::TAllocator< void * > &allocator)
~TVector_pointer_void()
Definition std-vector.cpp:19
Definition std-vector.h:16
u32 GetSize_extend_(u32 count)
Definition std-vector.h:126
T * begin()
Definition std-vector.h:113
void insert(T *pos, u32 count, const T &val)
Definition std-vector.h:50
TVector(Allocator const &allocator)
Definition std-vector.h:31
T * Insert_raw(T *pIt, u32 pCount)
Definition std-vector.h:62
void DestroyElement_(T *start, T *end)
Definition std-vector.h:136
T * end()
Definition std-vector.h:115
Allocator mAllocator
Definition std-vector.h:154
T * insert(T *pos, const T &val)
Definition std-vector.h:44
u32 capacity()
Definition std-vector.h:124
T * pEnd_
Definition std-vector.h:156
u32 mCapacity
Definition std-vector.h:157
void DestroyElement_all_()
Definition std-vector.h:142
void clear()
Definition std-vector.h:152
u32 size()
Definition std-vector.h:117
T * pBegin_
Definition std-vector.h:155
T * erase(T *start, T *end)
Definition std-vector.h:144
~TVector()
Definition std-vector.h:39
extendFunc pfnExtend_
Definition std-vector.h:158
unsigned long u32
Definition types.h:10