]>
Commit | Line | Data |
---|---|---|
c801d85f | 1 | /////////////////////////////////////////////////////////////////////////////// |
ce7208d4 | 2 | // Name: wx/dynarray.h |
c801d85f KB |
3 | // Purpose: auto-resizable (i.e. dynamic) array support |
4 | // Author: Vadim Zeitlin | |
3bfa4402 | 5 | // Modified by: |
c801d85f KB |
6 | // Created: 12.09.97 |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> | |
65571936 | 9 | // Licence: wxWindows licence |
c801d85f KB |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _DYNARRAY_H | |
13 | #define _DYNARRAY_H | |
14 | ||
c801d85f | 15 | #include "wx/defs.h" |
c801d85f | 16 | |
01871bf6 | 17 | #if wxUSE_STD_CONTAINERS |
df5168c4 MB |
18 | #include "wx/beforestd.h" |
19 | #include <vector> | |
20 | #include <algorithm> | |
21 | #include "wx/afterstd.h" | |
df5168c4 MB |
22 | #endif |
23 | ||
1a931653 VZ |
24 | /* |
25 | This header defines the dynamic arrays and object arrays (i.e. arrays which | |
26 | own their elements). Dynamic means that the arrays grow automatically as | |
27 | needed. | |
28 | ||
29 | These macros are ugly (especially if you look in the sources ;-), but they | |
30 | allow us to define "template" classes without actually using templates and so | |
31 | this works with all compilers (and may be also much faster to compile even | |
32 | with a compiler which does support templates). The arrays defined with these | |
33 | macros are type-safe. | |
34 | ||
35 | Range checking is performed in debug build for both arrays and objarrays but | |
36 | not in release build - so using an invalid index will just lead to a crash | |
37 | then. | |
38 | ||
39 | Note about memory usage: arrays never shrink automatically (although you may | |
40 | use Shrink() function explicitly), they only grow, so loading 10 millions in | |
41 | an array only to delete them 2 lines below might be a bad idea if the array | |
42 | object is not going to be destroyed soon. However, as it does free memory | |
43 | when destroyed, it is ok if the array is a local variable. | |
44 | */ | |
c801d85f KB |
45 | |
46 | // ---------------------------------------------------------------------------- | |
47 | // constants | |
48 | // ---------------------------------------------------------------------------- | |
49 | ||
1a931653 VZ |
50 | /* |
51 | The initial size by which an array grows when an element is added default | |
52 | value avoids allocate one or two bytes when the array is created which is | |
53 | rather inefficient | |
c801d85f | 54 | */ |
1a931653 | 55 | #define WX_ARRAY_DEFAULT_INITIAL_SIZE (16) |
c801d85f | 56 | |
35d5da67 VZ |
57 | #define _WX_ERROR_REMOVE "removing inexistent element in wxArray::Remove" |
58 | ||
c801d85f KB |
59 | // ---------------------------------------------------------------------------- |
60 | // types | |
61 | // ---------------------------------------------------------------------------- | |
62 | ||
1a931653 VZ |
63 | /* |
64 | Callback compare function for quick sort. | |
3b0b5f13 | 65 | |
1a931653 VZ |
66 | It must return negative value, 0 or positive value if the first item is |
67 | less than, equal to or greater than the second one. | |
c801d85f | 68 | */ |
90350682 VZ |
69 | extern "C" |
70 | { | |
0661ec39 | 71 | typedef int (wxCMPFUNC_CONV *CMPFUNC)(const void* pItem1, const void* pItem2); |
90350682 | 72 | } |
c801d85f KB |
73 | |
74 | // ---------------------------------------------------------------------------- | |
1a931653 VZ |
75 | // Base class managing data having size of type 'long' (not used directly) |
76 | // | |
77 | // NB: for efficiency this often used class has no virtual functions (hence no | |
78 | // virtual table), even dtor is *not* virtual. If used as expected it | |
79 | // won't create any problems because ARRAYs from DEFINE_ARRAY have no dtor | |
80 | // at all, so it's not too important if it's not called (this happens when | |
81 | // you cast "SomeArray *" as "BaseArray *" and then delete it) | |
c801d85f | 82 | // ---------------------------------------------------------------------------- |
1a931653 | 83 | |
01871bf6 | 84 | #if wxUSE_STD_CONTAINERS |
df5168c4 | 85 | |
f700f98c | 86 | template<class T> |
638205e5 | 87 | class wxArray_SortFunction |
f700f98c MB |
88 | { |
89 | public: | |
90 | typedef int (wxCMPFUNC_CONV *CMPFUNC)(T* pItem1, T* pItem2); | |
91 | ||
92 | wxArray_SortFunction(CMPFUNC f) : m_f(f) { } | |
93 | bool operator()(const T& i1, const T& i2) | |
94 | { return m_f((T*)&i1, (T*)&i2) < 0; } | |
95 | private: | |
96 | CMPFUNC m_f; | |
97 | }; | |
98 | ||
99 | template<class T, typename F> | |
638205e5 | 100 | class wxSortedArray_SortFunction |
f700f98c MB |
101 | { |
102 | public: | |
103 | typedef F CMPFUNC; | |
104 | ||
105 | wxSortedArray_SortFunction(CMPFUNC f) : m_f(f) { } | |
106 | bool operator()(const T& i1, const T& i2) | |
107 | { return m_f(i1, i2) < 0; } | |
108 | private: | |
109 | CMPFUNC m_f; | |
110 | }; | |
111 | ||
df5168c4 | 112 | #define _WX_DECLARE_BASEARRAY(T, name, classexp) \ |
f700f98c MB |
113 | typedef int (wxCMPFUNC_CONV *CMPFUN##name)(T pItem1, T pItem2); \ |
114 | typedef wxSortedArray_SortFunction<T, CMPFUN##name> name##_Predicate; \ | |
115 | _WX_DECLARE_BASEARRAY_2(T, name, name##_Predicate, classexp) | |
116 | ||
117 | #define _WX_DECLARE_BASEARRAY_2(T, name, predicate, classexp) \ | |
df5168c4 MB |
118 | classexp name : public std::vector<T> \ |
119 | { \ | |
f700f98c MB |
120 | typedef predicate Predicate; \ |
121 | typedef predicate::CMPFUNC SCMPFUNC; \ | |
7df07b10 | 122 | public: \ |
f700f98c | 123 | typedef wxArray_SortFunction<T>::CMPFUNC CMPFUNC; \ |
35d5da67 | 124 | \ |
df5168c4 | 125 | public: \ |
35d5da67 VZ |
126 | typedef T base_type; \ |
127 | \ | |
b1f8bee5 VZ |
128 | name() : std::vector<T>() { } \ |
129 | name(size_type n) : std::vector<T>(n) { } \ | |
130 | name(size_type n, const_reference v) : std::vector<T>(n, v) { } \ | |
131 | \ | |
df5168c4 MB |
132 | void Empty() { clear(); } \ |
133 | void Clear() { clear(); } \ | |
134 | void Alloc(size_t uiSize) { reserve(uiSize); } \ | |
35d5da67 | 135 | void Shrink() { name tmp(*this); swap(tmp); } \ |
df5168c4 MB |
136 | \ |
137 | size_t GetCount() const { return size(); } \ | |
138 | void SetCount(size_t n, T v = T()) { resize(n, v); } \ | |
139 | bool IsEmpty() const { return empty(); } \ | |
140 | size_t Count() const { return size(); } \ | |
141 | \ | |
df5168c4 MB |
142 | T& Item(size_t uiIndex) const \ |
143 | { wxASSERT( uiIndex < size() ); return (T&)operator[](uiIndex); } \ | |
35d5da67 | 144 | T& Last() const { return Item(size() - 1); } \ |
df5168c4 | 145 | \ |
35d5da67 VZ |
146 | int Index(T item, bool bFromEnd = false) const \ |
147 | { \ | |
148 | if ( bFromEnd ) \ | |
149 | { \ | |
150 | const const_reverse_iterator b = rbegin(), \ | |
151 | e = rend(); \ | |
152 | for ( const_reverse_iterator i = b; i != e; ++i ) \ | |
153 | if ( *i == item ) \ | |
154 | return (int)(i - b); \ | |
155 | } \ | |
156 | else \ | |
157 | { \ | |
158 | const const_iterator b = begin(), \ | |
159 | e = end(); \ | |
160 | for ( const_iterator i = b; i != e; ++i ) \ | |
161 | if ( *i == item ) \ | |
162 | return (int)(i - b); \ | |
163 | } \ | |
164 | \ | |
165 | return wxNOT_FOUND; \ | |
166 | } \ | |
167 | int Index(T lItem, CMPFUNC fnCompare) const \ | |
168 | { \ | |
169 | Predicate p((SCMPFUNC)fnCompare); \ | |
170 | const_iterator i = std::lower_bound(begin(), end(), lItem, p);\ | |
171 | return i != end() && !p(lItem, *i) ? (int)(i - begin()) \ | |
172 | : wxNOT_FOUND; \ | |
173 | } \ | |
174 | size_t IndexForInsert(T lItem, CMPFUNC fnCompare) const \ | |
175 | { \ | |
176 | Predicate p((SCMPFUNC)fnCompare); \ | |
177 | const_iterator i = std::lower_bound(begin(), end(), lItem, p);\ | |
178 | return i - begin(); \ | |
179 | } \ | |
df5168c4 MB |
180 | void Add(T lItem, size_t nInsert = 1) \ |
181 | { insert(end(), nInsert, lItem); } \ | |
35d5da67 VZ |
182 | size_t Add(T lItem, CMPFUNC fnCompare) \ |
183 | { \ | |
184 | size_t n = IndexForInsert(lItem, fnCompare); \ | |
185 | Insert(lItem, n); \ | |
186 | return n; \ | |
187 | } \ | |
df5168c4 MB |
188 | void Insert(T lItem, size_t uiIndex, size_t nInsert = 1) \ |
189 | { insert(begin() + uiIndex, nInsert, lItem); } \ | |
35d5da67 VZ |
190 | void Remove(T lItem) \ |
191 | { \ | |
192 | int n = Index(lItem); \ | |
193 | wxCHECK_RET( n != wxNOT_FOUND, _WX_ERROR_REMOVE ); \ | |
194 | RemoveAt((size_t)n); \ | |
195 | } \ | |
df5168c4 MB |
196 | void RemoveAt(size_t uiIndex, size_t nRemove = 1) \ |
197 | { erase(begin() + uiIndex, begin() + uiIndex + nRemove); } \ | |
198 | \ | |
199 | void Sort(CMPFUNC fCmp) \ | |
200 | { \ | |
f700f98c | 201 | wxArray_SortFunction<T> p(fCmp); \ |
df5168c4 MB |
202 | std::sort(begin(), end(), p); \ |
203 | } \ | |
df5168c4 MB |
204 | } |
205 | ||
01871bf6 | 206 | #else // if !wxUSE_STD_CONTAINERS |
df5168c4 | 207 | |
5a1cad6e GD |
208 | #define _WX_DECLARE_BASEARRAY(T, name, classexp) \ |
209 | classexp name \ | |
210 | { \ | |
01871bf6 | 211 | typedef CMPFUNC SCMPFUNC; /* for compatibility wuth wxUSE_STD_CONTAINERS */ \ |
5a1cad6e GD |
212 | public: \ |
213 | name(); \ | |
214 | name(const name& array); \ | |
215 | name& operator=(const name& src); \ | |
216 | ~name(); \ | |
217 | \ | |
218 | void Empty() { m_nCount = 0; } \ | |
219 | void Clear(); \ | |
7788fc40 | 220 | void Alloc(size_t n) { if ( n > m_nSize ) Realloc(n); } \ |
5a1cad6e GD |
221 | void Shrink(); \ |
222 | \ | |
2abb9d2f | 223 | size_t GetCount() const { return m_nCount; } \ |
9cde322b | 224 | void SetCount(size_t n, T defval = T()); \ |
2abb9d2f VZ |
225 | bool IsEmpty() const { return m_nCount == 0; } \ |
226 | size_t Count() const { return m_nCount; } \ | |
5a1cad6e | 227 | \ |
75d7ef36 | 228 | typedef T base_type; \ |
2abb9d2f | 229 | \ |
5a1cad6e GD |
230 | protected: \ |
231 | T& Item(size_t uiIndex) const \ | |
232 | { wxASSERT( uiIndex < m_nCount ); return m_pItems[uiIndex]; } \ | |
233 | T& operator[](size_t uiIndex) const { return Item(uiIndex); } \ | |
234 | \ | |
68379eaf | 235 | int Index(T lItem, bool bFromEnd = false) const; \ |
5a1cad6e GD |
236 | int Index(T lItem, CMPFUNC fnCompare) const; \ |
237 | size_t IndexForInsert(T lItem, CMPFUNC fnCompare) const; \ | |
3b0b5f13 | 238 | void Add(T lItem, size_t nInsert = 1); \ |
6992d326 | 239 | size_t Add(T lItem, CMPFUNC fnCompare); \ |
3b0b5f13 | 240 | void Insert(T lItem, size_t uiIndex, size_t nInsert = 1); \ |
5a1cad6e | 241 | void Remove(T lItem); \ |
3b0b5f13 | 242 | void RemoveAt(size_t uiIndex, size_t nRemove = 1); \ |
5a1cad6e GD |
243 | \ |
244 | void Sort(CMPFUNC fnCompare); \ | |
245 | \ | |
df5168c4 MB |
246 | /* *minimal* STL-ish interface, for derived classes */ \ |
247 | typedef T value_type; \ | |
248 | typedef value_type* iterator; \ | |
249 | typedef const value_type* const_iterator; \ | |
250 | typedef value_type& reference; \ | |
251 | typedef const value_type& const_reference; \ | |
252 | typedef int difference_type; \ | |
253 | typedef size_t size_type; \ | |
254 | \ | |
255 | void assign(const_iterator first, const_iterator last); \ | |
256 | void assign(size_type n, const_reference v); \ | |
257 | size_type capacity() const { return m_nSize; } \ | |
df5168c4 MB |
258 | iterator erase(iterator first, iterator last) \ |
259 | { \ | |
260 | size_type idx = first - begin(); \ | |
261 | RemoveAt(idx, last - first); \ | |
262 | return begin() + idx; \ | |
263 | } \ | |
264 | iterator erase(iterator it) { return erase(it, it + 1); } \ | |
265 | void insert(iterator it, size_type n, const value_type& v) \ | |
266 | { Insert(v, it - begin(), n); } \ | |
267 | iterator insert(iterator it, const value_type& v = value_type()) \ | |
268 | { \ | |
269 | size_type idx = it - begin(); \ | |
270 | Insert(v, idx); \ | |
271 | return begin() + idx; \ | |
272 | } \ | |
273 | void insert(iterator it, const_iterator first, const_iterator last);\ | |
df5168c4 MB |
274 | void pop_back() { RemoveAt(size() - 1); } \ |
275 | void push_back(const value_type& v) { Add(v); } \ | |
7788fc40 | 276 | void reserve(size_type n) { Alloc(n); } \ |
bf004951 VZ |
277 | void resize(size_type n, value_type v = value_type()) \ |
278 | { SetCount(n, v); } \ | |
df5168c4 MB |
279 | \ |
280 | iterator begin() { return m_pItems; } \ | |
281 | iterator end() { return m_pItems + m_nCount; } \ | |
282 | const_iterator begin() const { return m_pItems; } \ | |
283 | const_iterator end() const { return m_pItems + m_nCount; } \ | |
5da0803c | 284 | \ |
b2794028 VZ |
285 | void swap(name& other) \ |
286 | { \ | |
1372f8cc VZ |
287 | wxSwap(m_nSize, other.m_nSize); \ |
288 | wxSwap(m_nCount, other.m_nCount); \ | |
289 | wxSwap(m_pItems, other.m_pItems); \ | |
b2794028 VZ |
290 | } \ |
291 | \ | |
5da0803c VZ |
292 | /* the following functions may be made directly public because */ \ |
293 | /* they don't use the type of the elements at all */ \ | |
294 | public: \ | |
295 | void clear() { Clear(); } \ | |
296 | bool empty() const { return IsEmpty(); } \ | |
297 | size_type max_size() const { return INT_MAX; } \ | |
298 | size_type size() const { return GetCount(); } \ | |
299 | \ | |
5a1cad6e | 300 | private: \ |
2abb9d2f VZ |
301 | void Grow(size_t nIncrement = 0); \ |
302 | bool Realloc(size_t nSize); \ | |
5a1cad6e GD |
303 | \ |
304 | size_t m_nSize, \ | |
305 | m_nCount; \ | |
306 | \ | |
307 | T *m_pItems; \ | |
e9bb94cf | 308 | } |
c801d85f | 309 | |
01871bf6 | 310 | #endif // !wxUSE_STD_CONTAINERS |
df5168c4 | 311 | |
c801d85f | 312 | // ============================================================================ |
1a931653 | 313 | // The private helper macros containing the core of the array classes |
c801d85f KB |
314 | // ============================================================================ |
315 | ||
1a931653 VZ |
316 | // Implementation notes: |
317 | // | |
318 | // JACS: Salford C++ doesn't like 'var->operator=' syntax, as in: | |
319 | // { ((wxBaseArray *)this)->operator=((const wxBaseArray&)src); | |
320 | // so using a temporary variable instead. | |
321 | // | |
322 | // The classes need a (even trivial) ~name() to link under Mac X | |
e90c1d2a | 323 | |
c801d85f | 324 | // ---------------------------------------------------------------------------- |
5a1cad6e | 325 | // _WX_DEFINE_TYPEARRAY: array for simple types |
c801d85f | 326 | // ---------------------------------------------------------------------------- |
1a931653 | 327 | |
01871bf6 | 328 | #if wxUSE_STD_CONTAINERS |
df5168c4 | 329 | |
35d5da67 VZ |
330 | // in STL case we don't need the entire base arrays hack as standard container |
331 | // don't suffer from alignment/storage problems as our home-grown do | |
df5168c4 | 332 | #define _WX_DEFINE_TYPEARRAY(T, name, base, classexp) \ |
35d5da67 | 333 | _WX_DECLARE_BASEARRAY(T, name, classexp) |
df5168c4 | 334 | |
d5d29b8a | 335 | #define _WX_DEFINE_TYPEARRAY_PTR(T, name, base, classexp) \ |
68379eaf | 336 | _WX_DEFINE_TYPEARRAY(T, name, base, classexp) |
6108e3fd | 337 | |
01871bf6 | 338 | #else // if !wxUSE_STD_CONTAINERS |
df5168c4 | 339 | |
6108e3fd | 340 | // common declaration used by both _WX_DEFINE_TYPEARRAY and |
d5d29b8a | 341 | // _WX_DEFINE_TYPEARRAY_PTR |
6108e3fd | 342 | #define _WX_DEFINE_TYPEARRAY_HELPER(T, name, base, classexp, ptrop) \ |
1d6560d7 VZ |
343 | wxCOMPILE_TIME_ASSERT2(sizeof(T) <= sizeof(base::base_type), \ |
344 | TypeTooBigToBeStoredIn##base, \ | |
345 | name); \ | |
5a1cad6e GD |
346 | typedef int (CMPFUNC_CONV *CMPFUNC##T)(T *pItem1, T *pItem2); \ |
347 | classexp name : public base \ | |
348 | { \ | |
349 | public: \ | |
350 | name() { } \ | |
351 | ~name() { } \ | |
352 | \ | |
5a1cad6e | 353 | T& operator[](size_t uiIndex) const \ |
df5168c4 | 354 | { return (T&)(base::operator[](uiIndex)); } \ |
5a1cad6e | 355 | T& Item(size_t uiIndex) const \ |
df5168c4 | 356 | { return (T&)(base::operator[](uiIndex)); } \ |
5a1cad6e | 357 | T& Last() const \ |
b4a980f4 | 358 | { return (T&)(base::operator[](GetCount() - 1)); } \ |
5a1cad6e | 359 | \ |
222702b1 WS |
360 | int Index(T lItem, bool bFromEnd = false) const \ |
361 | { return base::Index((base_type)lItem, bFromEnd); } \ | |
5a1cad6e | 362 | \ |
222702b1 WS |
363 | void Add(T lItem, size_t nInsert = 1) \ |
364 | { base::Add((base_type)lItem, nInsert); } \ | |
365 | void Insert(T lItem, size_t uiIndex, size_t nInsert = 1) \ | |
366 | { base::Insert((base_type)lItem, uiIndex, nInsert) ; } \ | |
5a1cad6e | 367 | \ |
3b0b5f13 VZ |
368 | void RemoveAt(size_t uiIndex, size_t nRemove = 1) \ |
369 | { base::RemoveAt(uiIndex, nRemove); } \ | |
222702b1 WS |
370 | void Remove(T lItem) \ |
371 | { int iIndex = Index(lItem); \ | |
35d5da67 | 372 | wxCHECK_RET( iIndex != wxNOT_FOUND, _WX_ERROR_REMOVE); \ |
5a1cad6e GD |
373 | base::RemoveAt((size_t)iIndex); } \ |
374 | \ | |
375 | void Sort(CMPFUNC##T fCmp) { base::Sort((CMPFUNC)fCmp); } \ | |
df5168c4 MB |
376 | \ |
377 | /* STL-like interface */ \ | |
378 | private: \ | |
379 | typedef base::iterator biterator; \ | |
380 | typedef base::const_iterator bconst_iterator; \ | |
381 | typedef base::value_type bvalue_type; \ | |
382 | typedef base::const_reference bconst_reference; \ | |
383 | public: \ | |
384 | typedef T value_type; \ | |
385 | typedef value_type* pointer; \ | |
386 | typedef const value_type* const_pointer; \ | |
387 | typedef value_type* iterator; \ | |
388 | typedef const value_type* const_iterator; \ | |
389 | typedef value_type& reference; \ | |
390 | typedef const value_type& const_reference; \ | |
391 | typedef base::difference_type difference_type; \ | |
392 | typedef base::size_type size_type; \ | |
393 | \ | |
394 | class reverse_iterator \ | |
395 | { \ | |
c514cd53 MB |
396 | typedef T value_type; \ |
397 | typedef value_type& reference; \ | |
398 | typedef value_type* pointer; \ | |
df5168c4 | 399 | typedef reverse_iterator itor; \ |
31222b7c VZ |
400 | friend inline itor operator+(int o, const itor& it) \ |
401 | { return it.m_ptr - o; } \ | |
402 | friend inline itor operator+(const itor& it, int o) \ | |
403 | { return it.m_ptr - o; } \ | |
404 | friend inline itor operator-(const itor& it, int o) \ | |
405 | { return it.m_ptr + o; } \ | |
406 | friend inline difference_type operator-(const itor& i1, \ | |
407 | const itor& i2) \ | |
408 | { return i1.m_ptr - i2.m_ptr; } \ | |
409 | \ | |
df5168c4 MB |
410 | public: \ |
411 | pointer m_ptr; \ | |
412 | reverse_iterator() : m_ptr(NULL) { } \ | |
413 | reverse_iterator(pointer ptr) : m_ptr(ptr) { } \ | |
414 | reverse_iterator(const itor& it) : m_ptr(it.m_ptr) { } \ | |
415 | reference operator*() const { return *m_ptr; } \ | |
6108e3fd | 416 | ptrop \ |
60d8e886 VZ |
417 | itor& operator++() { --m_ptr; return *this; } \ |
418 | const itor operator++(int) \ | |
df5168c4 | 419 | { reverse_iterator tmp = *this; --m_ptr; return tmp; } \ |
60d8e886 VZ |
420 | itor& operator--() { ++m_ptr; return *this; } \ |
421 | const itor operator--(int) { itor tmp = *this; ++m_ptr; return tmp; }\ | |
fbfb8bcc VZ |
422 | bool operator ==(const itor& it) const { return m_ptr == it.m_ptr; }\ |
423 | bool operator !=(const itor& it) const { return m_ptr != it.m_ptr; }\ | |
df5168c4 MB |
424 | }; \ |
425 | \ | |
426 | class const_reverse_iterator \ | |
427 | { \ | |
c514cd53 MB |
428 | typedef T value_type; \ |
429 | typedef const value_type& reference; \ | |
430 | typedef const value_type* pointer; \ | |
df5168c4 | 431 | typedef const_reverse_iterator itor; \ |
31222b7c VZ |
432 | friend inline itor operator+(int o, const itor& it) \ |
433 | { return it.m_ptr - o; } \ | |
434 | friend inline itor operator+(const itor& it, int o) \ | |
435 | { return it.m_ptr - o; } \ | |
436 | friend inline itor operator-(const itor& it, int o) \ | |
437 | { return it.m_ptr + o; } \ | |
438 | friend inline difference_type operator-(const itor& i1, \ | |
439 | const itor& i2) \ | |
440 | { return i1.m_ptr - i2.m_ptr; } \ | |
441 | \ | |
df5168c4 MB |
442 | public: \ |
443 | pointer m_ptr; \ | |
444 | const_reverse_iterator() : m_ptr(NULL) { } \ | |
445 | const_reverse_iterator(pointer ptr) : m_ptr(ptr) { } \ | |
446 | const_reverse_iterator(const itor& it) : m_ptr(it.m_ptr) { } \ | |
447 | const_reverse_iterator(const reverse_iterator& it) : m_ptr(it.m_ptr) { }\ | |
448 | reference operator*() const { return *m_ptr; } \ | |
6108e3fd | 449 | ptrop \ |
60d8e886 VZ |
450 | itor& operator++() { --m_ptr; return *this; } \ |
451 | const itor operator++(int) \ | |
df5168c4 | 452 | { itor tmp = *this; --m_ptr; return tmp; } \ |
60d8e886 VZ |
453 | itor& operator--() { ++m_ptr; return *this; } \ |
454 | const itor operator--(int) { itor tmp = *this; ++m_ptr; return tmp; }\ | |
fbfb8bcc VZ |
455 | bool operator ==(const itor& it) const { return m_ptr == it.m_ptr; }\ |
456 | bool operator !=(const itor& it) const { return m_ptr != it.m_ptr; }\ | |
df5168c4 MB |
457 | }; \ |
458 | \ | |
5041b46f | 459 | name(size_type n) { assign(n, value_type()); } \ |
584ad2a3 MB |
460 | name(size_type n, const_reference v) { assign(n, v); } \ |
461 | name(const_iterator first, const_iterator last) \ | |
462 | { assign(first, last); } \ | |
df5168c4 MB |
463 | void assign(const_iterator first, const_iterator last) \ |
464 | { base::assign((bconst_iterator)first, (bconst_iterator)last); } \ | |
465 | void assign(size_type n, const_reference v) \ | |
466 | { base::assign(n, (bconst_reference)v); } \ | |
467 | reference back() { return *(end() - 1); } \ | |
468 | const_reference back() const { return *(end() - 1); } \ | |
469 | iterator begin() { return (iterator)base::begin(); } \ | |
470 | const_iterator begin() const { return (const_iterator)base::begin(); }\ | |
471 | size_type capacity() const { return base::capacity(); } \ | |
df5168c4 MB |
472 | iterator end() { return (iterator)base::end(); } \ |
473 | const_iterator end() const { return (const_iterator)base::end(); } \ | |
474 | iterator erase(iterator first, iterator last) \ | |
475 | { return (iterator)base::erase((biterator)first, (biterator)last); }\ | |
476 | iterator erase(iterator it) \ | |
477 | { return (iterator)base::erase((biterator)it); } \ | |
478 | reference front() { return *begin(); } \ | |
479 | const_reference front() const { return *begin(); } \ | |
480 | void insert(iterator it, size_type n, const_reference v) \ | |
481 | { base::insert((biterator)it, n, (bconst_reference)v); } \ | |
482 | iterator insert(iterator it, const_reference v = value_type()) \ | |
483 | { return (iterator)base::insert((biterator)it, (bconst_reference)v); }\ | |
484 | void insert(iterator it, const_iterator first, const_iterator last) \ | |
485 | { base::insert((biterator)it, (bconst_iterator)first, \ | |
486 | (bconst_iterator)last); } \ | |
df5168c4 MB |
487 | void pop_back() { base::pop_back(); } \ |
488 | void push_back(const_reference v) \ | |
489 | { base::push_back((bconst_reference)v); } \ | |
490 | reverse_iterator rbegin() { return reverse_iterator(end() - 1); } \ | |
491 | const_reverse_iterator rbegin() const; \ | |
492 | reverse_iterator rend() { return reverse_iterator(begin() - 1); } \ | |
493 | const_reverse_iterator rend() const; \ | |
47b378bd | 494 | void reserve(size_type n) { base::reserve(n); } \ |
bf004951 VZ |
495 | void resize(size_type n, value_type v = value_type()) \ |
496 | { base::resize(n, v); } \ | |
b2794028 | 497 | void swap(name& other) { base::swap(other); } \ |
31222b7c VZ |
498 | } |
499 | ||
6108e3fd VZ |
500 | #define _WX_PTROP pointer operator->() const { return m_ptr; } |
501 | #define _WX_PTROP_NONE | |
502 | ||
503 | #define _WX_DEFINE_TYPEARRAY(T, name, base, classexp) \ | |
504 | _WX_DEFINE_TYPEARRAY_HELPER(T, name, base, classexp, _WX_PTROP) | |
d5d29b8a | 505 | #define _WX_DEFINE_TYPEARRAY_PTR(T, name, base, classexp) \ |
6108e3fd | 506 | _WX_DEFINE_TYPEARRAY_HELPER(T, name, base, classexp, _WX_PTROP_NONE) |
df5168c4 | 507 | |
01871bf6 | 508 | #endif // !wxUSE_STD_CONTAINERS |
c801d85f | 509 | |
3bfa4402 | 510 | // ---------------------------------------------------------------------------- |
5a1cad6e GD |
511 | // _WX_DEFINE_SORTED_TYPEARRAY: sorted array for simple data types |
512 | // cannot handle types with size greater than pointer because of sorting | |
3bfa4402 | 513 | // ---------------------------------------------------------------------------- |
1a931653 | 514 | |
df5168c4 | 515 | #define _WX_DEFINE_SORTED_TYPEARRAY_2(T, name, base, defcomp, classexp, comptype)\ |
1d6560d7 VZ |
516 | wxCOMPILE_TIME_ASSERT2(sizeof(T) <= sizeof(base::base_type), \ |
517 | TypeTooBigToBeStoredInSorted##base, \ | |
518 | name); \ | |
5a1cad6e GD |
519 | classexp name : public base \ |
520 | { \ | |
f700f98c | 521 | typedef comptype SCMPFUNC; \ |
5a1cad6e | 522 | public: \ |
df5168c4 | 523 | name(comptype fn defcomp) { m_fnCompare = fn; } \ |
5a1cad6e GD |
524 | \ |
525 | name& operator=(const name& src) \ | |
526 | { base* temp = (base*) this; \ | |
527 | (*temp) = ((const base&)src); \ | |
528 | m_fnCompare = src.m_fnCompare; \ | |
529 | return *this; } \ | |
530 | \ | |
531 | T& operator[](size_t uiIndex) const \ | |
df5168c4 | 532 | { return (T&)(base::operator[](uiIndex)); } \ |
5a1cad6e | 533 | T& Item(size_t uiIndex) const \ |
df5168c4 | 534 | { return (T&)(base::operator[](uiIndex)); } \ |
5a1cad6e | 535 | T& Last() const \ |
df5168c4 | 536 | { return (T&)(base::operator[](size() - 1)); } \ |
5a1cad6e | 537 | \ |
222702b1 WS |
538 | int Index(T lItem) const \ |
539 | { return base::Index(lItem, (CMPFUNC)m_fnCompare); } \ | |
5a1cad6e | 540 | \ |
222702b1 WS |
541 | size_t IndexForInsert(T lItem) const \ |
542 | { return base::IndexForInsert(lItem, (CMPFUNC)m_fnCompare); } \ | |
5a1cad6e GD |
543 | \ |
544 | void AddAt(T item, size_t index) \ | |
df5168c4 | 545 | { base::insert(begin() + index, item); } \ |
5a1cad6e | 546 | \ |
222702b1 WS |
547 | size_t Add(T lItem) \ |
548 | { return base::Add(lItem, (CMPFUNC)m_fnCompare); } \ | |
0287ae5c VZ |
549 | void push_back(T lItem) \ |
550 | { Add(lItem); } \ | |
5a1cad6e | 551 | \ |
3b0b5f13 | 552 | void RemoveAt(size_t uiIndex, size_t nRemove = 1) \ |
df5168c4 | 553 | { base::erase(begin() + uiIndex, begin() + uiIndex + nRemove); } \ |
222702b1 WS |
554 | void Remove(T lItem) \ |
555 | { int iIndex = Index(lItem); \ | |
35d5da67 | 556 | wxCHECK_RET( iIndex != wxNOT_FOUND, _WX_ERROR_REMOVE ); \ |
df5168c4 | 557 | base::erase(begin() + iIndex); } \ |
5a1cad6e GD |
558 | \ |
559 | private: \ | |
df5168c4 | 560 | comptype m_fnCompare; \ |
3bfa4402 VZ |
561 | } |
562 | ||
df5168c4 | 563 | |
c801d85f | 564 | // ---------------------------------------------------------------------------- |
1a931653 | 565 | // _WX_DECLARE_OBJARRAY: an array for pointers to type T with owning semantics |
c801d85f | 566 | // ---------------------------------------------------------------------------- |
1a931653 | 567 | |
5a1cad6e GD |
568 | #define _WX_DECLARE_OBJARRAY(T, name, base, classexp) \ |
569 | typedef int (CMPFUNC_CONV *CMPFUNC##T)(T **pItem1, T **pItem2); \ | |
df5168c4 | 570 | classexp name : protected base \ |
5a1cad6e GD |
571 | { \ |
572 | typedef int (CMPFUNC_CONV *CMPFUNC##base)(void **pItem1, void **pItem2); \ | |
df5168c4 | 573 | typedef base base_array; \ |
5a1cad6e GD |
574 | public: \ |
575 | name() { } \ | |
576 | name(const name& src); \ | |
577 | name& operator=(const name& src); \ | |
578 | \ | |
579 | ~name(); \ | |
580 | \ | |
43de4157 VS |
581 | void Alloc(size_t count) { base::reserve(count); } \ |
582 | void reserve(size_t count) { base::reserve(count); } \ | |
df5168c4 MB |
583 | size_t GetCount() const { return base_array::size(); } \ |
584 | size_t size() const { return base_array::size(); } \ | |
585 | bool IsEmpty() const { return base_array::empty(); } \ | |
009c4392 | 586 | bool empty() const { return base_array::empty(); } \ |
df5168c4 MB |
587 | size_t Count() const { return base_array::size(); } \ |
588 | void Shrink() { base::Shrink(); } \ | |
589 | \ | |
5a1cad6e | 590 | T& operator[](size_t uiIndex) const \ |
df5168c4 | 591 | { return *(T*)base::operator[](uiIndex); } \ |
5a1cad6e | 592 | T& Item(size_t uiIndex) const \ |
df5168c4 | 593 | { return *(T*)base::operator[](uiIndex); } \ |
5a1cad6e | 594 | T& Last() const \ |
df5168c4 | 595 | { return *(T*)(base::operator[](size() - 1)); } \ |
5a1cad6e | 596 | \ |
222702b1 | 597 | int Index(const T& lItem, bool bFromEnd = false) const; \ |
5a1cad6e | 598 | \ |
222702b1 | 599 | void Add(const T& lItem, size_t nInsert = 1); \ |
5a1cad6e | 600 | void Add(const T* pItem) \ |
df5168c4 MB |
601 | { base::push_back((T*)pItem); } \ |
602 | void push_back(const T* pItem) \ | |
603 | { base::push_back((T*)pItem); } \ | |
222702b1 WS |
604 | void push_back(const T& lItem) \ |
605 | { Add(lItem); } \ | |
5a1cad6e | 606 | \ |
222702b1 | 607 | void Insert(const T& lItem, size_t uiIndex, size_t nInsert = 1); \ |
5a1cad6e | 608 | void Insert(const T* pItem, size_t uiIndex) \ |
df5168c4 | 609 | { base::insert(begin() + uiIndex, (T*)pItem); } \ |
5a1cad6e | 610 | \ |
df5168c4 MB |
611 | void Empty() { DoEmpty(); base::clear(); } \ |
612 | void Clear() { DoEmpty(); base::clear(); } \ | |
5a1cad6e GD |
613 | \ |
614 | T* Detach(size_t uiIndex) \ | |
df5168c4 MB |
615 | { T* p = (T*)base::operator[](uiIndex); \ |
616 | base::erase(begin() + uiIndex); return p; } \ | |
3b0b5f13 | 617 | void RemoveAt(size_t uiIndex, size_t nRemove = 1); \ |
5a1cad6e GD |
618 | \ |
619 | void Sort(CMPFUNC##T fCmp) { base::Sort((CMPFUNC##base)fCmp); } \ | |
620 | \ | |
621 | private: \ | |
622 | void DoEmpty(); \ | |
623 | void DoCopy(const name& src); \ | |
c801d85f KB |
624 | } |
625 | ||
1a931653 VZ |
626 | // ============================================================================ |
627 | // The public macros for declaration and definition of the dynamic arrays | |
628 | // ============================================================================ | |
629 | ||
630 | // Please note that for each macro WX_FOO_ARRAY we also have | |
631 | // WX_FOO_EXPORTED_ARRAY and WX_FOO_USER_EXPORTED_ARRAY which are exactly the | |
632 | // same except that they use an additional __declspec(dllexport) or equivalent | |
633 | // under Windows if needed. | |
634 | // | |
77ffb593 | 635 | // The first (just EXPORTED) macros do it if wxWidgets was compiled as a DLL |
1a931653 VZ |
636 | // and so must be used used inside the library. The second kind (USER_EXPORTED) |
637 | // allow the user code to do it when it wants. This is needed if you have a dll | |
638 | // that wants to export a wxArray daubed with your own import/export goo. | |
639 | // | |
640 | // Finally, you can define the macro below as something special to modify the | |
d13b34d3 | 641 | // arrays defined by a simple WX_FOO_ARRAY as well. By default is empty. |
1a931653 VZ |
642 | #define wxARRAY_DEFAULT_EXPORT |
643 | ||
644 | // ---------------------------------------------------------------------------- | |
5a1cad6e GD |
645 | // WX_DECLARE_BASEARRAY(T, name) declare an array class named "name" containing |
646 | // the elements of type T | |
647 | // ---------------------------------------------------------------------------- | |
648 | ||
649 | #define WX_DECLARE_BASEARRAY(T, name) \ | |
650 | WX_DECLARE_USER_EXPORTED_BASEARRAY(T, name, wxARRAY_DEFAULT_EXPORT) | |
651 | ||
652 | #define WX_DECLARE_EXPORTED_BASEARRAY(T, name) \ | |
53a2db12 | 653 | WX_DECLARE_USER_EXPORTED_BASEARRAY(T, name, WXDLLIMPEXP_CORE) |
5a1cad6e GD |
654 | |
655 | #define WX_DECLARE_USER_EXPORTED_BASEARRAY(T, name, expmode) \ | |
656 | typedef T _wxArray##name; \ | |
657 | _WX_DECLARE_BASEARRAY(_wxArray##name, name, class expmode) | |
658 | ||
659 | // ---------------------------------------------------------------------------- | |
660 | // WX_DEFINE_TYPEARRAY(T, name, base) define an array class named "name" deriving | |
661 | // from class "base" containing the elements of type T | |
1a931653 VZ |
662 | // |
663 | // Note that the class defined has only inline function and doesn't take any | |
664 | // space at all so there is no size penalty for defining multiple array classes | |
c801d85f | 665 | // ---------------------------------------------------------------------------- |
c801d85f | 666 | |
5a1cad6e | 667 | #define WX_DEFINE_TYPEARRAY(T, name, base) \ |
68559fd5 | 668 | WX_DEFINE_TYPEARRAY_WITH_DECL(T, name, base, class wxARRAY_DEFAULT_EXPORT) |
1a931653 | 669 | |
d5d29b8a VZ |
670 | #define WX_DEFINE_TYPEARRAY_PTR(T, name, base) \ |
671 | WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, base, class wxARRAY_DEFAULT_EXPORT) | |
6108e3fd | 672 | |
5a1cad6e | 673 | #define WX_DEFINE_EXPORTED_TYPEARRAY(T, name, base) \ |
53a2db12 | 674 | WX_DEFINE_TYPEARRAY_WITH_DECL(T, name, base, class WXDLLIMPEXP_CORE) |
1a931653 | 675 | |
d5d29b8a | 676 | #define WX_DEFINE_EXPORTED_TYPEARRAY_PTR(T, name, base) \ |
53a2db12 | 677 | WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, base, class WXDLLIMPEXP_CORE) |
6108e3fd | 678 | |
68559fd5 VZ |
679 | #define WX_DEFINE_USER_EXPORTED_TYPEARRAY(T, name, base, expdecl) \ |
680 | WX_DEFINE_TYPEARRAY_WITH_DECL(T, name, base, class expdecl) | |
681 | ||
d5d29b8a VZ |
682 | #define WX_DEFINE_USER_EXPORTED_TYPEARRAY_PTR(T, name, base, expdecl) \ |
683 | WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, base, class expdecl) | |
6108e3fd | 684 | |
68559fd5 | 685 | #define WX_DEFINE_TYPEARRAY_WITH_DECL(T, name, base, classdecl) \ |
df5168c4 | 686 | typedef T _wxArray##name; \ |
68559fd5 | 687 | _WX_DEFINE_TYPEARRAY(_wxArray##name, name, base, classdecl) |
1a931653 | 688 | |
d5d29b8a | 689 | #define WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, base, classdecl) \ |
6108e3fd | 690 | typedef T _wxArray##name; \ |
d5d29b8a | 691 | _WX_DEFINE_TYPEARRAY_PTR(_wxArray##name, name, base, classdecl) |
6108e3fd | 692 | |
1a931653 | 693 | // ---------------------------------------------------------------------------- |
5a1cad6e | 694 | // WX_DEFINE_SORTED_TYPEARRAY: this is the same as the previous macro, but it |
1a931653 VZ |
695 | // defines a sorted array. |
696 | // | |
697 | // Differences: | |
698 | // 1) it must be given a COMPARE function in ctor which takes 2 items of type | |
699 | // T* and should return -1, 0 or +1 if the first one is less/greater | |
700 | // than/equal to the second one. | |
701 | // 2) the Add() method inserts the item in such was that the array is always | |
702 | // sorted (it uses the COMPARE function) | |
703 | // 3) it has no Sort() method because it's always sorted | |
704 | // 4) Index() method is much faster (the sorted arrays use binary search | |
705 | // instead of linear one), but Add() is slower. | |
706 | // 5) there is no Insert() method because you can't insert an item into the | |
707 | // given position in a sorted array but there is IndexForInsert()/AddAt() | |
708 | // pair which may be used to optimize a common operation of "insert only if | |
709 | // not found" | |
710 | // | |
711 | // Note that you have to specify the comparison function when creating the | |
712 | // objects of this array type. If, as in 99% of cases, the comparison function | |
5a1cad6e GD |
713 | // is the same for all objects of a class, WX_DEFINE_SORTED_TYPEARRAY_CMP below |
714 | // is more convenient. | |
1a931653 VZ |
715 | // |
716 | // Summary: use this class when the speed of Index() function is important, use | |
717 | // the normal arrays otherwise. | |
c801d85f KB |
718 | // ---------------------------------------------------------------------------- |
719 | ||
c75cc2e8 VZ |
720 | // we need a macro which expands to nothing to pass correct number of |
721 | // parameters to a nested macro invocation even when we don't have anything to | |
722 | // pass it | |
723 | #define wxARRAY_EMPTY | |
17e656b0 | 724 | |
5a1cad6e GD |
725 | #define WX_DEFINE_SORTED_TYPEARRAY(T, name, base) \ |
726 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, base, \ | |
727 | wxARRAY_DEFAULT_EXPORT) | |
a497618a | 728 | |
5a1cad6e | 729 | #define WX_DEFINE_SORTED_EXPORTED_TYPEARRAY(T, name, base) \ |
53a2db12 | 730 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, base, WXDLLIMPEXP_CORE) |
a497618a | 731 | |
5a1cad6e GD |
732 | #define WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, base, expmode) \ |
733 | typedef T _wxArray##name; \ | |
3e49e577 MB |
734 | typedef int (CMPFUNC_CONV *SCMPFUNC##name)(T pItem1, T pItem2); \ |
735 | _WX_DEFINE_SORTED_TYPEARRAY_2(_wxArray##name, name, base, \ | |
c75cc2e8 | 736 | wxARRAY_EMPTY, class expmode, SCMPFUNC##name) |
1a931653 VZ |
737 | |
738 | // ---------------------------------------------------------------------------- | |
5a1cad6e | 739 | // WX_DEFINE_SORTED_TYPEARRAY_CMP: exactly the same as above but the comparison |
1a931653 VZ |
740 | // function is provided by this macro and the objects of this class have a |
741 | // default constructor which just uses it. | |
742 | // | |
743 | // The arguments are: the element type, the comparison function and the array | |
744 | // name | |
745 | // | |
5a1cad6e GD |
746 | // NB: this is, of course, how WX_DEFINE_SORTED_TYPEARRAY() should have worked |
747 | // from the very beginning - unfortunately I didn't think about this earlier | |
1a931653 | 748 | // ---------------------------------------------------------------------------- |
76314141 | 749 | |
5a1cad6e GD |
750 | #define WX_DEFINE_SORTED_TYPEARRAY_CMP(T, cmpfunc, name, base) \ |
751 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, base, \ | |
752 | wxARRAY_DEFAULT_EXPORT) | |
76314141 | 753 | |
5a1cad6e GD |
754 | #define WX_DEFINE_SORTED_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, base) \ |
755 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, base, \ | |
53a2db12 | 756 | WXDLLIMPEXP_CORE) |
1a931653 | 757 | |
5a1cad6e GD |
758 | #define WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, base, \ |
759 | expmode) \ | |
1a931653 | 760 | typedef T _wxArray##name; \ |
3e49e577 MB |
761 | typedef int (CMPFUNC_CONV *SCMPFUNC##name)(T pItem1, T pItem2); \ |
762 | _WX_DEFINE_SORTED_TYPEARRAY_2(_wxArray##name, name, base, = cmpfunc, \ | |
763 | class expmode, SCMPFUNC##name) | |
1a931653 VZ |
764 | |
765 | // ---------------------------------------------------------------------------- | |
766 | // WX_DECLARE_OBJARRAY(T, name): this macro generates a new array class | |
767 | // named "name" which owns the objects of type T it contains, i.e. it will | |
768 | // delete them when it is destroyed. | |
769 | // | |
770 | // An element is of type T*, but arguments of type T& are taken (see below!) | |
771 | // and T& is returned. | |
772 | // | |
773 | // Don't use this for simple types such as "int" or "long"! | |
1a931653 VZ |
774 | // |
775 | // Note on Add/Insert functions: | |
776 | // 1) function(T*) gives the object to the array, i.e. it will delete the | |
777 | // object when it's removed or in the array's dtor | |
778 | // 2) function(T&) will create a copy of the object and work with it | |
779 | // | |
780 | // Also: | |
781 | // 1) Remove() will delete the object after removing it from the array | |
782 | // 2) Detach() just removes the object from the array (returning pointer to it) | |
783 | // | |
784 | // NB1: Base type T should have an accessible copy ctor if Add(T&) is used | |
785 | // NB2: Never ever cast a array to it's base type: as dtor is not virtual | |
786 | // and so you risk having at least the memory leaks and probably worse | |
787 | // | |
788 | // Some functions of this class are not inline, so it takes some space to | |
789 | // define new class from this template even if you don't use it - which is not | |
790 | // the case for the simple (non-object) array classes | |
791 | // | |
1a931653 VZ |
792 | // To use an objarray class you must |
793 | // #include "dynarray.h" | |
794 | // WX_DECLARE_OBJARRAY(element_type, list_class_name) | |
795 | // #include "arrimpl.cpp" | |
796 | // WX_DEFINE_OBJARRAY(list_class_name) // name must be the same as above! | |
797 | // | |
798 | // This is necessary because at the moment of DEFINE_OBJARRAY class parsing the | |
799 | // element_type must be fully defined (i.e. forward declaration is not | |
800 | // enough), while WX_DECLARE_OBJARRAY may be done anywhere. The separation of | |
801 | // two allows to break cicrcular dependencies with classes which have member | |
802 | // variables of objarray type. | |
803 | // ---------------------------------------------------------------------------- | |
804 | ||
805 | #define WX_DECLARE_OBJARRAY(T, name) \ | |
806 | WX_DECLARE_USER_EXPORTED_OBJARRAY(T, name, wxARRAY_DEFAULT_EXPORT) | |
807 | ||
808 | #define WX_DECLARE_EXPORTED_OBJARRAY(T, name) \ | |
53a2db12 | 809 | WX_DECLARE_USER_EXPORTED_OBJARRAY(T, name, WXDLLIMPEXP_CORE) |
1a931653 | 810 | |
fd68cfdb | 811 | #define WX_DECLARE_OBJARRAY_WITH_DECL(T, name, decl) \ |
1a931653 | 812 | typedef T _wxObjArray##name; \ |
fd68cfdb | 813 | _WX_DECLARE_OBJARRAY(_wxObjArray##name, name, wxArrayPtrVoid, decl) |
68379eaf | 814 | |
fd68cfdb VS |
815 | #define WX_DECLARE_USER_EXPORTED_OBJARRAY(T, name, expmode) \ |
816 | WX_DECLARE_OBJARRAY_WITH_DECL(T, name, class expmode) | |
1a931653 VZ |
817 | |
818 | // WX_DEFINE_OBJARRAY is going to be redefined when arrimpl.cpp is included, | |
819 | // try to provoke a human-understandable error if it used incorrectly. | |
820 | // | |
821 | // there is no real need for 3 different macros in the DEFINE case but do it | |
822 | // anyhow for consistency | |
823 | #define WX_DEFINE_OBJARRAY(name) DidYouIncludeArrimplCpp | |
824 | #define WX_DEFINE_EXPORTED_OBJARRAY(name) WX_DEFINE_OBJARRAY(name) | |
76314141 | 825 | #define WX_DEFINE_USER_EXPORTED_OBJARRAY(name) WX_DEFINE_OBJARRAY(name) |
76314141 | 826 | |
5a1cad6e GD |
827 | // ---------------------------------------------------------------------------- |
828 | // Some commonly used predefined base arrays | |
829 | // ---------------------------------------------------------------------------- | |
830 | ||
eee614d3 VS |
831 | WX_DECLARE_USER_EXPORTED_BASEARRAY(const void *, wxBaseArrayPtrVoid, |
832 | WXDLLIMPEXP_BASE); | |
1ffc8d7a | 833 | WX_DECLARE_USER_EXPORTED_BASEARRAY(char, wxBaseArrayChar, WXDLLIMPEXP_BASE); |
6108e3fd VZ |
834 | WX_DECLARE_USER_EXPORTED_BASEARRAY(short, wxBaseArrayShort, WXDLLIMPEXP_BASE); |
835 | WX_DECLARE_USER_EXPORTED_BASEARRAY(int, wxBaseArrayInt, WXDLLIMPEXP_BASE); | |
836 | WX_DECLARE_USER_EXPORTED_BASEARRAY(long, wxBaseArrayLong, WXDLLIMPEXP_BASE); | |
d2213b1f | 837 | WX_DECLARE_USER_EXPORTED_BASEARRAY(size_t, wxBaseArraySizeT, WXDLLIMPEXP_BASE); |
6108e3fd | 838 | WX_DECLARE_USER_EXPORTED_BASEARRAY(double, wxBaseArrayDouble, WXDLLIMPEXP_BASE); |
5a1cad6e GD |
839 | |
840 | // ---------------------------------------------------------------------------- | |
841 | // Convenience macros to define arrays from base arrays | |
842 | // ---------------------------------------------------------------------------- | |
843 | ||
844 | #define WX_DEFINE_ARRAY(T, name) \ | |
845 | WX_DEFINE_TYPEARRAY(T, name, wxBaseArrayPtrVoid) | |
d5d29b8a VZ |
846 | #define WX_DEFINE_ARRAY_PTR(T, name) \ |
847 | WX_DEFINE_TYPEARRAY_PTR(T, name, wxBaseArrayPtrVoid) | |
5a1cad6e GD |
848 | #define WX_DEFINE_EXPORTED_ARRAY(T, name) \ |
849 | WX_DEFINE_EXPORTED_TYPEARRAY(T, name, wxBaseArrayPtrVoid) | |
d5d29b8a VZ |
850 | #define WX_DEFINE_EXPORTED_ARRAY_PTR(T, name) \ |
851 | WX_DEFINE_EXPORTED_TYPEARRAY_PTR(T, name, wxBaseArrayPtrVoid) | |
852 | #define WX_DEFINE_ARRAY_WITH_DECL_PTR(T, name, decl) \ | |
853 | WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, wxBaseArrayPtrVoid, decl) | |
5a1cad6e | 854 | #define WX_DEFINE_USER_EXPORTED_ARRAY(T, name, expmode) \ |
c75cc2e8 | 855 | WX_DEFINE_TYPEARRAY_WITH_DECL(T, name, wxBaseArrayPtrVoid, wxARRAY_EMPTY expmode) |
d5d29b8a | 856 | #define WX_DEFINE_USER_EXPORTED_ARRAY_PTR(T, name, expmode) \ |
c75cc2e8 | 857 | WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, wxBaseArrayPtrVoid, wxARRAY_EMPTY expmode) |
5a1cad6e | 858 | |
1ffc8d7a VZ |
859 | #define WX_DEFINE_ARRAY_CHAR(T, name) \ |
860 | WX_DEFINE_TYPEARRAY_PTR(T, name, wxBaseArrayChar) | |
861 | #define WX_DEFINE_EXPORTED_ARRAY_CHAR(T, name) \ | |
862 | WX_DEFINE_EXPORTED_TYPEARRAY_PTR(T, name, wxBaseArrayChar) | |
863 | #define WX_DEFINE_USER_EXPORTED_ARRAY_CHAR(T, name, expmode) \ | |
c75cc2e8 | 864 | WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, wxBaseArrayChar, wxARRAY_EMPTY expmode) |
1ffc8d7a | 865 | |
5a1cad6e | 866 | #define WX_DEFINE_ARRAY_SHORT(T, name) \ |
d5d29b8a | 867 | WX_DEFINE_TYPEARRAY_PTR(T, name, wxBaseArrayShort) |
5a1cad6e | 868 | #define WX_DEFINE_EXPORTED_ARRAY_SHORT(T, name) \ |
d5d29b8a | 869 | WX_DEFINE_EXPORTED_TYPEARRAY_PTR(T, name, wxBaseArrayShort) |
5a1cad6e | 870 | #define WX_DEFINE_USER_EXPORTED_ARRAY_SHORT(T, name, expmode) \ |
c75cc2e8 | 871 | WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, wxBaseArrayShort, wxARRAY_EMPTY expmode) |
5a1cad6e GD |
872 | |
873 | #define WX_DEFINE_ARRAY_INT(T, name) \ | |
d5d29b8a | 874 | WX_DEFINE_TYPEARRAY_PTR(T, name, wxBaseArrayInt) |
5a1cad6e | 875 | #define WX_DEFINE_EXPORTED_ARRAY_INT(T, name) \ |
d5d29b8a | 876 | WX_DEFINE_EXPORTED_TYPEARRAY_PTR(T, name, wxBaseArrayInt) |
5a1cad6e | 877 | #define WX_DEFINE_USER_EXPORTED_ARRAY_INT(T, name, expmode) \ |
c75cc2e8 | 878 | WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, wxBaseArrayInt, wxARRAY_EMPTY expmode) |
5a1cad6e GD |
879 | |
880 | #define WX_DEFINE_ARRAY_LONG(T, name) \ | |
d5d29b8a | 881 | WX_DEFINE_TYPEARRAY_PTR(T, name, wxBaseArrayLong) |
5a1cad6e | 882 | #define WX_DEFINE_EXPORTED_ARRAY_LONG(T, name) \ |
d5d29b8a | 883 | WX_DEFINE_EXPORTED_TYPEARRAY_PTR(T, name, wxBaseArrayLong) |
5a1cad6e | 884 | #define WX_DEFINE_USER_EXPORTED_ARRAY_LONG(T, name, expmode) \ |
c75cc2e8 | 885 | WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, wxBaseArrayLong, wxARRAY_EMPTY expmode) |
5a1cad6e | 886 | |
d2213b1f VZ |
887 | #define WX_DEFINE_ARRAY_SIZE_T(T, name) \ |
888 | WX_DEFINE_TYPEARRAY_PTR(T, name, wxBaseArraySizeT) | |
889 | #define WX_DEFINE_EXPORTED_ARRAY_SIZE_T(T, name) \ | |
890 | WX_DEFINE_EXPORTED_TYPEARRAY_PTR(T, name, wxBaseArraySizeT) | |
891 | #define WX_DEFINE_USER_EXPORTED_ARRAY_SIZE_T(T, name, expmode) \ | |
c75cc2e8 | 892 | WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, wxBaseArraySizeT, wxARRAY_EMPTY expmode) |
d2213b1f | 893 | |
5a1cad6e | 894 | #define WX_DEFINE_ARRAY_DOUBLE(T, name) \ |
d5d29b8a | 895 | WX_DEFINE_TYPEARRAY_PTR(T, name, wxBaseArrayDouble) |
5a1cad6e | 896 | #define WX_DEFINE_EXPORTED_ARRAY_DOUBLE(T, name) \ |
d5d29b8a | 897 | WX_DEFINE_EXPORTED_TYPEARRAY_PTR(T, name, wxBaseArrayDouble) |
5a1cad6e | 898 | #define WX_DEFINE_USER_EXPORTED_ARRAY_DOUBLE(T, name, expmode) \ |
c75cc2e8 | 899 | WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, wxBaseArrayDouble, wxARRAY_EMPTY expmode) |
5a1cad6e GD |
900 | |
901 | // ---------------------------------------------------------------------------- | |
902 | // Convenience macros to define sorted arrays from base arrays | |
903 | // ---------------------------------------------------------------------------- | |
904 | ||
905 | #define WX_DEFINE_SORTED_ARRAY(T, name) \ | |
906 | WX_DEFINE_SORTED_TYPEARRAY(T, name, wxBaseArrayPtrVoid) | |
907 | #define WX_DEFINE_SORTED_EXPORTED_ARRAY(T, name) \ | |
908 | WX_DEFINE_SORTED_EXPORTED_TYPEARRAY(T, name, wxBaseArrayPtrVoid) | |
909 | #define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY(T, name, expmode) \ | |
c75cc2e8 | 910 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArrayPtrVoid, wxARRAY_EMPTY expmode) |
5a1cad6e | 911 | |
1ffc8d7a VZ |
912 | #define WX_DEFINE_SORTED_ARRAY_CHAR(T, name) \ |
913 | WX_DEFINE_SORTED_TYPEARRAY(T, name, wxBaseArrayChar) | |
914 | #define WX_DEFINE_SORTED_EXPORTED_ARRAY_CHAR(T, name) \ | |
915 | WX_DEFINE_SORTED_EXPORTED_TYPEARRAY(T, name, wxBaseArrayChar) | |
916 | #define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_CHAR(T, name, expmode) \ | |
c75cc2e8 | 917 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArrayChar, wxARRAY_EMPTY expmode) |
1ffc8d7a | 918 | |
5a1cad6e GD |
919 | #define WX_DEFINE_SORTED_ARRAY_SHORT(T, name) \ |
920 | WX_DEFINE_SORTED_TYPEARRAY(T, name, wxBaseArrayShort) | |
921 | #define WX_DEFINE_SORTED_EXPORTED_ARRAY_SHORT(T, name) \ | |
922 | WX_DEFINE_SORTED_EXPORTED_TYPEARRAY(T, name, wxBaseArrayShort) | |
923 | #define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_SHORT(T, name, expmode) \ | |
c75cc2e8 | 924 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArrayShort, wxARRAY_EMPTY expmode) |
5a1cad6e GD |
925 | |
926 | #define WX_DEFINE_SORTED_ARRAY_INT(T, name) \ | |
927 | WX_DEFINE_SORTED_TYPEARRAY(T, name, wxBaseArrayInt) | |
928 | #define WX_DEFINE_SORTED_EXPORTED_ARRAY_INT(T, name) \ | |
929 | WX_DEFINE_SORTED_EXPORTED_TYPEARRAY(T, name, wxBaseArrayInt) | |
930 | #define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_INT(T, name, expmode) \ | |
931 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArrayInt, expmode) | |
932 | ||
933 | #define WX_DEFINE_SORTED_ARRAY_LONG(T, name) \ | |
934 | WX_DEFINE_SORTED_TYPEARRAY(T, name, wxBaseArrayLong) | |
935 | #define WX_DEFINE_SORTED_EXPORTED_ARRAY_LONG(T, name) \ | |
936 | WX_DEFINE_SORTED_EXPORTED_TYPEARRAY(T, name, wxBaseArrayLong) | |
937 | #define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_LONG(T, name, expmode) \ | |
938 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArrayLong, expmode) | |
939 | ||
d2213b1f VZ |
940 | #define WX_DEFINE_SORTED_ARRAY_SIZE_T(T, name) \ |
941 | WX_DEFINE_SORTED_TYPEARRAY(T, name, wxBaseArraySizeT) | |
942 | #define WX_DEFINE_SORTED_EXPORTED_ARRAY_SIZE_T(T, name) \ | |
943 | WX_DEFINE_SORTED_EXPORTED_TYPEARRAY(T, name, wxBaseArraySizeT) | |
944 | #define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_SIZE_T(T, name, expmode) \ | |
c75cc2e8 | 945 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArraySizeT, wxARRAY_EMPTY expmode) |
d2213b1f | 946 | |
5a1cad6e GD |
947 | // ---------------------------------------------------------------------------- |
948 | // Convenience macros to define sorted arrays from base arrays | |
949 | // ---------------------------------------------------------------------------- | |
950 | ||
951 | #define WX_DEFINE_SORTED_ARRAY_CMP(T, cmpfunc, name) \ | |
952 | WX_DEFINE_SORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayPtrVoid) | |
953 | #define WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP(T, cmpfunc, name) \ | |
954 | WX_DEFINE_SORTED_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayPtrVoid) | |
955 | #define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_CMP(T, cmpfunc, \ | |
956 | name, expmode) \ | |
957 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, \ | |
c75cc2e8 VZ |
958 | wxBaseArrayPtrVoid, \ |
959 | wxARRAY_EMPTY expmode) | |
5a1cad6e | 960 | |
1ffc8d7a VZ |
961 | #define WX_DEFINE_SORTED_ARRAY_CMP_CHAR(T, cmpfunc, name) \ |
962 | WX_DEFINE_SORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayChar) | |
963 | #define WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP_CHAR(T, cmpfunc, name) \ | |
964 | WX_DEFINE_SORTED_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayChar) | |
c75cc2e8 | 965 | #define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_CMP_CHAR(T, cmpfunc, \ |
1ffc8d7a VZ |
966 | name, expmode) \ |
967 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, \ | |
c75cc2e8 VZ |
968 | wxBaseArrayChar, \ |
969 | wxARRAY_EMPTY expmode) | |
1ffc8d7a | 970 | |
5a1cad6e GD |
971 | #define WX_DEFINE_SORTED_ARRAY_CMP_SHORT(T, cmpfunc, name) \ |
972 | WX_DEFINE_SORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayShort) | |
973 | #define WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP_SHORT(T, cmpfunc, name) \ | |
974 | WX_DEFINE_SORTED_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayShort) | |
975 | #define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_CMP_SHORT(T, cmpfunc, \ | |
976 | name, expmode) \ | |
977 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, \ | |
c75cc2e8 VZ |
978 | wxBaseArrayShort, \ |
979 | wxARRAY_EMPTY expmode) | |
5a1cad6e GD |
980 | |
981 | #define WX_DEFINE_SORTED_ARRAY_CMP_INT(T, cmpfunc, name) \ | |
982 | WX_DEFINE_SORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayInt) | |
983 | #define WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP_INT(T, cmpfunc, name) \ | |
984 | WX_DEFINE_SORTED_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayInt) | |
985 | #define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_CMP_INT(T, cmpfunc, \ | |
986 | name, expmode) \ | |
987 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, \ | |
c75cc2e8 VZ |
988 | wxBaseArrayInt, \ |
989 | wxARRAY_EMPTY expmode) | |
5a1cad6e GD |
990 | |
991 | #define WX_DEFINE_SORTED_ARRAY_CMP_LONG(T, cmpfunc, name) \ | |
992 | WX_DEFINE_SORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayLong) | |
993 | #define WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP_LONG(T, cmpfunc, name) \ | |
994 | WX_DEFINE_SORTED_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayLong) | |
995 | #define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_CMP_LONG(T, cmpfunc, \ | |
996 | name, expmode) \ | |
997 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, \ | |
c75cc2e8 VZ |
998 | wxBaseArrayLong, \ |
999 | wxARRAY_EMPTY expmode) | |
5a1cad6e | 1000 | |
d2213b1f VZ |
1001 | #define WX_DEFINE_SORTED_ARRAY_CMP_SIZE_T(T, cmpfunc, name) \ |
1002 | WX_DEFINE_SORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArraySizeT) | |
1003 | #define WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP_SIZE_T(T, cmpfunc, name) \ | |
1004 | WX_DEFINE_SORTED_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArraySizeT) | |
1005 | #define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_CMP_SIZE_T(T, cmpfunc, \ | |
1006 | name, expmode) \ | |
1007 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, \ | |
c75cc2e8 VZ |
1008 | wxBaseArraySizeT, \ |
1009 | wxARRAY_EMPTY expmode) | |
d2213b1f | 1010 | |
c801d85f | 1011 | // ---------------------------------------------------------------------------- |
1a931653 | 1012 | // Some commonly used predefined arrays |
c801d85f KB |
1013 | // ---------------------------------------------------------------------------- |
1014 | ||
6108e3fd VZ |
1015 | WX_DEFINE_USER_EXPORTED_ARRAY_SHORT(short, wxArrayShort, class WXDLLIMPEXP_BASE); |
1016 | WX_DEFINE_USER_EXPORTED_ARRAY_INT(int, wxArrayInt, class WXDLLIMPEXP_BASE); | |
87cc1cc7 | 1017 | WX_DEFINE_USER_EXPORTED_ARRAY_DOUBLE(double, wxArrayDouble, class WXDLLIMPEXP_BASE); |
6108e3fd | 1018 | WX_DEFINE_USER_EXPORTED_ARRAY_LONG(long, wxArrayLong, class WXDLLIMPEXP_BASE); |
d5d29b8a | 1019 | WX_DEFINE_USER_EXPORTED_ARRAY_PTR(void *, wxArrayPtrVoid, class WXDLLIMPEXP_BASE); |
c801d85f | 1020 | |
2b9bd418 | 1021 | // ----------------------------------------------------------------------------- |
0cbff120 | 1022 | // convenience macros |
2b9bd418 VZ |
1023 | // ----------------------------------------------------------------------------- |
1024 | ||
bf7f7793 RR |
1025 | // prepend all element of one array to another one; e.g. if first array contains |
1026 | // elements X,Y,Z and the second contains A,B,C (in those orders), then the | |
1027 | // first array will be result as A,B,C,X,Y,Z | |
1028 | #define WX_PREPEND_ARRAY(array, other) \ | |
1029 | { \ | |
1030 | size_t wxAAcnt = (other).size(); \ | |
cd643444 | 1031 | (array).reserve(wxAAcnt); \ |
bf7f7793 RR |
1032 | for ( size_t wxAAn = 0; wxAAn < wxAAcnt; wxAAn++ ) \ |
1033 | { \ | |
1034 | (array).Insert((other)[wxAAn], wxAAn); \ | |
1035 | } \ | |
1036 | } | |
1037 | ||
4f6aed9c VZ |
1038 | // append all element of one array to another one |
1039 | #define WX_APPEND_ARRAY(array, other) \ | |
1040 | { \ | |
17a1ebd1 | 1041 | size_t wxAAcnt = (other).size(); \ |
cd643444 | 1042 | (array).reserve(wxAAcnt); \ |
17a1ebd1 | 1043 | for ( size_t wxAAn = 0; wxAAn < wxAAcnt; wxAAn++ ) \ |
4f6aed9c | 1044 | { \ |
17a1ebd1 | 1045 | (array).push_back((other)[wxAAn]); \ |
4f6aed9c VZ |
1046 | } \ |
1047 | } | |
1048 | ||
2b9bd418 VZ |
1049 | // delete all array elements |
1050 | // | |
1051 | // NB: the class declaration of the array elements must be visible from the | |
1052 | // place where you use this macro, otherwise the proper destructor may not | |
1053 | // be called (a decent compiler should give a warning about it, but don't | |
1054 | // count on it)! | |
1055 | #define WX_CLEAR_ARRAY(array) \ | |
1056 | { \ | |
17a1ebd1 VZ |
1057 | size_t wxAAcnt = (array).size(); \ |
1058 | for ( size_t wxAAn = 0; wxAAn < wxAAcnt; wxAAn++ ) \ | |
2b9bd418 | 1059 | { \ |
17a1ebd1 | 1060 | delete (array)[wxAAn]; \ |
2b9bd418 | 1061 | } \ |
2c356747 | 1062 | \ |
df5168c4 | 1063 | (array).clear(); \ |
2b9bd418 | 1064 | } |
a497618a | 1065 | |
c801d85f | 1066 | #endif // _DYNARRAY_H |