]>
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 | |
df5168c4 MB |
17 | #if wxUSE_STL |
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 | |
df5168c4 MB |
84 | #if wxUSE_STL |
85 | ||
f700f98c MB |
86 | template<class T> |
87 | class WXDLLIMPEXP_BASE wxArray_SortFunction | |
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> | |
100 | class WXDLLIMPEXP_BASE wxSortedArray_SortFunction | |
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 | ||
206 | #else // if !wxUSE_STL | |
207 | ||
5a1cad6e GD |
208 | #define _WX_DECLARE_BASEARRAY(T, name, classexp) \ |
209 | classexp name \ | |
210 | { \ | |
f700f98c | 211 | typedef CMPFUNC SCMPFUNC; /* for compatibility wuth wxUSE_STL */ \ |
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 | { \ | |
287 | const size_t savedSize = m_nSize; \ | |
288 | const size_t savedCount = m_nCount; \ | |
289 | T * const savedItems = m_pItems; \ | |
290 | \ | |
291 | m_nSize = other.m_nSize; \ | |
292 | m_nCount = other.m_nCount; \ | |
293 | m_pItems = other.m_pItems; \ | |
294 | \ | |
295 | other.m_nSize = savedSize; \ | |
296 | other.m_nCount = savedCount; \ | |
297 | other.m_pItems = savedItems; \ | |
298 | } \ | |
299 | \ | |
5da0803c VZ |
300 | /* the following functions may be made directly public because */ \ |
301 | /* they don't use the type of the elements at all */ \ | |
302 | public: \ | |
303 | void clear() { Clear(); } \ | |
304 | bool empty() const { return IsEmpty(); } \ | |
305 | size_type max_size() const { return INT_MAX; } \ | |
306 | size_type size() const { return GetCount(); } \ | |
307 | \ | |
5a1cad6e | 308 | private: \ |
2abb9d2f VZ |
309 | void Grow(size_t nIncrement = 0); \ |
310 | bool Realloc(size_t nSize); \ | |
5a1cad6e GD |
311 | \ |
312 | size_t m_nSize, \ | |
313 | m_nCount; \ | |
314 | \ | |
315 | T *m_pItems; \ | |
e9bb94cf | 316 | } |
c801d85f | 317 | |
df5168c4 MB |
318 | #endif // !wxUSE_STL |
319 | ||
c801d85f | 320 | // ============================================================================ |
1a931653 | 321 | // The private helper macros containing the core of the array classes |
c801d85f KB |
322 | // ============================================================================ |
323 | ||
1a931653 VZ |
324 | // Implementation notes: |
325 | // | |
326 | // JACS: Salford C++ doesn't like 'var->operator=' syntax, as in: | |
327 | // { ((wxBaseArray *)this)->operator=((const wxBaseArray&)src); | |
328 | // so using a temporary variable instead. | |
329 | // | |
330 | // The classes need a (even trivial) ~name() to link under Mac X | |
e90c1d2a | 331 | |
c801d85f | 332 | // ---------------------------------------------------------------------------- |
5a1cad6e | 333 | // _WX_DEFINE_TYPEARRAY: array for simple types |
c801d85f | 334 | // ---------------------------------------------------------------------------- |
1a931653 | 335 | |
df5168c4 MB |
336 | #if wxUSE_STL |
337 | ||
35d5da67 VZ |
338 | // in STL case we don't need the entire base arrays hack as standard container |
339 | // don't suffer from alignment/storage problems as our home-grown do | |
df5168c4 | 340 | #define _WX_DEFINE_TYPEARRAY(T, name, base, classexp) \ |
35d5da67 | 341 | _WX_DECLARE_BASEARRAY(T, name, classexp) |
df5168c4 | 342 | |
d5d29b8a | 343 | #define _WX_DEFINE_TYPEARRAY_PTR(T, name, base, classexp) \ |
68379eaf | 344 | _WX_DEFINE_TYPEARRAY(T, name, base, classexp) |
6108e3fd | 345 | |
df5168c4 MB |
346 | #else // if !wxUSE_STL |
347 | ||
6108e3fd | 348 | // common declaration used by both _WX_DEFINE_TYPEARRAY and |
d5d29b8a | 349 | // _WX_DEFINE_TYPEARRAY_PTR |
6108e3fd | 350 | #define _WX_DEFINE_TYPEARRAY_HELPER(T, name, base, classexp, ptrop) \ |
1d6560d7 VZ |
351 | wxCOMPILE_TIME_ASSERT2(sizeof(T) <= sizeof(base::base_type), \ |
352 | TypeTooBigToBeStoredIn##base, \ | |
353 | name); \ | |
5a1cad6e GD |
354 | typedef int (CMPFUNC_CONV *CMPFUNC##T)(T *pItem1, T *pItem2); \ |
355 | classexp name : public base \ | |
356 | { \ | |
357 | public: \ | |
358 | name() { } \ | |
359 | ~name() { } \ | |
360 | \ | |
5a1cad6e | 361 | T& operator[](size_t uiIndex) const \ |
df5168c4 | 362 | { return (T&)(base::operator[](uiIndex)); } \ |
5a1cad6e | 363 | T& Item(size_t uiIndex) const \ |
df5168c4 | 364 | { return (T&)(base::operator[](uiIndex)); } \ |
5a1cad6e | 365 | T& Last() const \ |
b4a980f4 | 366 | { return (T&)(base::operator[](GetCount() - 1)); } \ |
5a1cad6e | 367 | \ |
222702b1 WS |
368 | int Index(T lItem, bool bFromEnd = false) const \ |
369 | { return base::Index((base_type)lItem, bFromEnd); } \ | |
5a1cad6e | 370 | \ |
222702b1 WS |
371 | void Add(T lItem, size_t nInsert = 1) \ |
372 | { base::Add((base_type)lItem, nInsert); } \ | |
373 | void Insert(T lItem, size_t uiIndex, size_t nInsert = 1) \ | |
374 | { base::Insert((base_type)lItem, uiIndex, nInsert) ; } \ | |
5a1cad6e | 375 | \ |
3b0b5f13 VZ |
376 | void RemoveAt(size_t uiIndex, size_t nRemove = 1) \ |
377 | { base::RemoveAt(uiIndex, nRemove); } \ | |
222702b1 WS |
378 | void Remove(T lItem) \ |
379 | { int iIndex = Index(lItem); \ | |
35d5da67 | 380 | wxCHECK_RET( iIndex != wxNOT_FOUND, _WX_ERROR_REMOVE); \ |
5a1cad6e GD |
381 | base::RemoveAt((size_t)iIndex); } \ |
382 | \ | |
383 | void Sort(CMPFUNC##T fCmp) { base::Sort((CMPFUNC)fCmp); } \ | |
df5168c4 MB |
384 | \ |
385 | /* STL-like interface */ \ | |
386 | private: \ | |
387 | typedef base::iterator biterator; \ | |
388 | typedef base::const_iterator bconst_iterator; \ | |
389 | typedef base::value_type bvalue_type; \ | |
390 | typedef base::const_reference bconst_reference; \ | |
391 | public: \ | |
392 | typedef T value_type; \ | |
393 | typedef value_type* pointer; \ | |
394 | typedef const value_type* const_pointer; \ | |
395 | typedef value_type* iterator; \ | |
396 | typedef const value_type* const_iterator; \ | |
397 | typedef value_type& reference; \ | |
398 | typedef const value_type& const_reference; \ | |
399 | typedef base::difference_type difference_type; \ | |
400 | typedef base::size_type size_type; \ | |
401 | \ | |
402 | class reverse_iterator \ | |
403 | { \ | |
c514cd53 MB |
404 | typedef T value_type; \ |
405 | typedef value_type& reference; \ | |
406 | typedef value_type* pointer; \ | |
df5168c4 | 407 | typedef reverse_iterator itor; \ |
31222b7c VZ |
408 | friend inline itor operator+(int o, const itor& it) \ |
409 | { return it.m_ptr - o; } \ | |
410 | friend inline itor operator+(const itor& it, int o) \ | |
411 | { return it.m_ptr - o; } \ | |
412 | friend inline itor operator-(const itor& it, int o) \ | |
413 | { return it.m_ptr + o; } \ | |
414 | friend inline difference_type operator-(const itor& i1, \ | |
415 | const itor& i2) \ | |
416 | { return i1.m_ptr - i2.m_ptr; } \ | |
417 | \ | |
df5168c4 MB |
418 | public: \ |
419 | pointer m_ptr; \ | |
420 | reverse_iterator() : m_ptr(NULL) { } \ | |
421 | reverse_iterator(pointer ptr) : m_ptr(ptr) { } \ | |
422 | reverse_iterator(const itor& it) : m_ptr(it.m_ptr) { } \ | |
423 | reference operator*() const { return *m_ptr; } \ | |
6108e3fd | 424 | ptrop \ |
60d8e886 VZ |
425 | itor& operator++() { --m_ptr; return *this; } \ |
426 | const itor operator++(int) \ | |
df5168c4 | 427 | { reverse_iterator tmp = *this; --m_ptr; return tmp; } \ |
60d8e886 VZ |
428 | itor& operator--() { ++m_ptr; return *this; } \ |
429 | const itor operator--(int) { itor tmp = *this; ++m_ptr; return tmp; }\ | |
fbfb8bcc VZ |
430 | bool operator ==(const itor& it) const { return m_ptr == it.m_ptr; }\ |
431 | bool operator !=(const itor& it) const { return m_ptr != it.m_ptr; }\ | |
df5168c4 MB |
432 | }; \ |
433 | \ | |
434 | class const_reverse_iterator \ | |
435 | { \ | |
c514cd53 MB |
436 | typedef T value_type; \ |
437 | typedef const value_type& reference; \ | |
438 | typedef const value_type* pointer; \ | |
df5168c4 | 439 | typedef const_reverse_iterator itor; \ |
31222b7c VZ |
440 | friend inline itor operator+(int o, const itor& it) \ |
441 | { return it.m_ptr - o; } \ | |
442 | friend inline itor operator+(const itor& it, int o) \ | |
443 | { return it.m_ptr - o; } \ | |
444 | friend inline itor operator-(const itor& it, int o) \ | |
445 | { return it.m_ptr + o; } \ | |
446 | friend inline difference_type operator-(const itor& i1, \ | |
447 | const itor& i2) \ | |
448 | { return i1.m_ptr - i2.m_ptr; } \ | |
449 | \ | |
df5168c4 MB |
450 | public: \ |
451 | pointer m_ptr; \ | |
452 | const_reverse_iterator() : m_ptr(NULL) { } \ | |
453 | const_reverse_iterator(pointer ptr) : m_ptr(ptr) { } \ | |
454 | const_reverse_iterator(const itor& it) : m_ptr(it.m_ptr) { } \ | |
455 | const_reverse_iterator(const reverse_iterator& it) : m_ptr(it.m_ptr) { }\ | |
456 | reference operator*() const { return *m_ptr; } \ | |
6108e3fd | 457 | ptrop \ |
60d8e886 VZ |
458 | itor& operator++() { --m_ptr; return *this; } \ |
459 | const itor operator++(int) \ | |
df5168c4 | 460 | { itor tmp = *this; --m_ptr; return tmp; } \ |
60d8e886 VZ |
461 | itor& operator--() { ++m_ptr; return *this; } \ |
462 | const itor operator--(int) { itor tmp = *this; ++m_ptr; return tmp; }\ | |
fbfb8bcc VZ |
463 | bool operator ==(const itor& it) const { return m_ptr == it.m_ptr; }\ |
464 | bool operator !=(const itor& it) const { return m_ptr != it.m_ptr; }\ | |
df5168c4 MB |
465 | }; \ |
466 | \ | |
5041b46f | 467 | name(size_type n) { assign(n, value_type()); } \ |
584ad2a3 MB |
468 | name(size_type n, const_reference v) { assign(n, v); } \ |
469 | name(const_iterator first, const_iterator last) \ | |
470 | { assign(first, last); } \ | |
df5168c4 MB |
471 | void assign(const_iterator first, const_iterator last) \ |
472 | { base::assign((bconst_iterator)first, (bconst_iterator)last); } \ | |
473 | void assign(size_type n, const_reference v) \ | |
474 | { base::assign(n, (bconst_reference)v); } \ | |
475 | reference back() { return *(end() - 1); } \ | |
476 | const_reference back() const { return *(end() - 1); } \ | |
477 | iterator begin() { return (iterator)base::begin(); } \ | |
478 | const_iterator begin() const { return (const_iterator)base::begin(); }\ | |
479 | size_type capacity() const { return base::capacity(); } \ | |
df5168c4 MB |
480 | iterator end() { return (iterator)base::end(); } \ |
481 | const_iterator end() const { return (const_iterator)base::end(); } \ | |
482 | iterator erase(iterator first, iterator last) \ | |
483 | { return (iterator)base::erase((biterator)first, (biterator)last); }\ | |
484 | iterator erase(iterator it) \ | |
485 | { return (iterator)base::erase((biterator)it); } \ | |
486 | reference front() { return *begin(); } \ | |
487 | const_reference front() const { return *begin(); } \ | |
488 | void insert(iterator it, size_type n, const_reference v) \ | |
489 | { base::insert((biterator)it, n, (bconst_reference)v); } \ | |
490 | iterator insert(iterator it, const_reference v = value_type()) \ | |
491 | { return (iterator)base::insert((biterator)it, (bconst_reference)v); }\ | |
492 | void insert(iterator it, const_iterator first, const_iterator last) \ | |
493 | { base::insert((biterator)it, (bconst_iterator)first, \ | |
494 | (bconst_iterator)last); } \ | |
df5168c4 MB |
495 | void pop_back() { base::pop_back(); } \ |
496 | void push_back(const_reference v) \ | |
497 | { base::push_back((bconst_reference)v); } \ | |
498 | reverse_iterator rbegin() { return reverse_iterator(end() - 1); } \ | |
499 | const_reverse_iterator rbegin() const; \ | |
500 | reverse_iterator rend() { return reverse_iterator(begin() - 1); } \ | |
501 | const_reverse_iterator rend() const; \ | |
47b378bd | 502 | void reserve(size_type n) { base::reserve(n); } \ |
bf004951 VZ |
503 | void resize(size_type n, value_type v = value_type()) \ |
504 | { base::resize(n, v); } \ | |
b2794028 | 505 | void swap(name& other) { base::swap(other); } \ |
31222b7c VZ |
506 | } |
507 | ||
6108e3fd VZ |
508 | #define _WX_PTROP pointer operator->() const { return m_ptr; } |
509 | #define _WX_PTROP_NONE | |
510 | ||
511 | #define _WX_DEFINE_TYPEARRAY(T, name, base, classexp) \ | |
512 | _WX_DEFINE_TYPEARRAY_HELPER(T, name, base, classexp, _WX_PTROP) | |
d5d29b8a | 513 | #define _WX_DEFINE_TYPEARRAY_PTR(T, name, base, classexp) \ |
6108e3fd | 514 | _WX_DEFINE_TYPEARRAY_HELPER(T, name, base, classexp, _WX_PTROP_NONE) |
df5168c4 MB |
515 | |
516 | #endif // !wxUSE_STL | |
c801d85f | 517 | |
3bfa4402 | 518 | // ---------------------------------------------------------------------------- |
5a1cad6e GD |
519 | // _WX_DEFINE_SORTED_TYPEARRAY: sorted array for simple data types |
520 | // cannot handle types with size greater than pointer because of sorting | |
3bfa4402 | 521 | // ---------------------------------------------------------------------------- |
1a931653 | 522 | |
df5168c4 | 523 | #define _WX_DEFINE_SORTED_TYPEARRAY_2(T, name, base, defcomp, classexp, comptype)\ |
1d6560d7 VZ |
524 | wxCOMPILE_TIME_ASSERT2(sizeof(T) <= sizeof(base::base_type), \ |
525 | TypeTooBigToBeStoredInSorted##base, \ | |
526 | name); \ | |
5a1cad6e GD |
527 | classexp name : public base \ |
528 | { \ | |
f700f98c | 529 | typedef comptype SCMPFUNC; \ |
5a1cad6e | 530 | public: \ |
df5168c4 | 531 | name(comptype fn defcomp) { m_fnCompare = fn; } \ |
5a1cad6e GD |
532 | \ |
533 | name& operator=(const name& src) \ | |
534 | { base* temp = (base*) this; \ | |
535 | (*temp) = ((const base&)src); \ | |
536 | m_fnCompare = src.m_fnCompare; \ | |
537 | return *this; } \ | |
538 | \ | |
539 | T& operator[](size_t uiIndex) const \ | |
df5168c4 | 540 | { return (T&)(base::operator[](uiIndex)); } \ |
5a1cad6e | 541 | T& Item(size_t uiIndex) const \ |
df5168c4 | 542 | { return (T&)(base::operator[](uiIndex)); } \ |
5a1cad6e | 543 | T& Last() const \ |
df5168c4 | 544 | { return (T&)(base::operator[](size() - 1)); } \ |
5a1cad6e | 545 | \ |
222702b1 WS |
546 | int Index(T lItem) const \ |
547 | { return base::Index(lItem, (CMPFUNC)m_fnCompare); } \ | |
5a1cad6e | 548 | \ |
222702b1 WS |
549 | size_t IndexForInsert(T lItem) const \ |
550 | { return base::IndexForInsert(lItem, (CMPFUNC)m_fnCompare); } \ | |
5a1cad6e GD |
551 | \ |
552 | void AddAt(T item, size_t index) \ | |
df5168c4 | 553 | { base::insert(begin() + index, item); } \ |
5a1cad6e | 554 | \ |
222702b1 WS |
555 | size_t Add(T lItem) \ |
556 | { return base::Add(lItem, (CMPFUNC)m_fnCompare); } \ | |
5a1cad6e | 557 | \ |
3b0b5f13 | 558 | void RemoveAt(size_t uiIndex, size_t nRemove = 1) \ |
df5168c4 | 559 | { base::erase(begin() + uiIndex, begin() + uiIndex + nRemove); } \ |
222702b1 WS |
560 | void Remove(T lItem) \ |
561 | { int iIndex = Index(lItem); \ | |
35d5da67 | 562 | wxCHECK_RET( iIndex != wxNOT_FOUND, _WX_ERROR_REMOVE ); \ |
df5168c4 | 563 | base::erase(begin() + iIndex); } \ |
5a1cad6e GD |
564 | \ |
565 | private: \ | |
df5168c4 | 566 | comptype m_fnCompare; \ |
3bfa4402 VZ |
567 | } |
568 | ||
df5168c4 | 569 | |
c801d85f | 570 | // ---------------------------------------------------------------------------- |
1a931653 | 571 | // _WX_DECLARE_OBJARRAY: an array for pointers to type T with owning semantics |
c801d85f | 572 | // ---------------------------------------------------------------------------- |
1a931653 | 573 | |
5a1cad6e GD |
574 | #define _WX_DECLARE_OBJARRAY(T, name, base, classexp) \ |
575 | typedef int (CMPFUNC_CONV *CMPFUNC##T)(T **pItem1, T **pItem2); \ | |
df5168c4 | 576 | classexp name : protected base \ |
5a1cad6e GD |
577 | { \ |
578 | typedef int (CMPFUNC_CONV *CMPFUNC##base)(void **pItem1, void **pItem2); \ | |
df5168c4 | 579 | typedef base base_array; \ |
5a1cad6e GD |
580 | public: \ |
581 | name() { } \ | |
582 | name(const name& src); \ | |
583 | name& operator=(const name& src); \ | |
584 | \ | |
585 | ~name(); \ | |
586 | \ | |
43de4157 VS |
587 | void Alloc(size_t count) { base::reserve(count); } \ |
588 | void reserve(size_t count) { base::reserve(count); } \ | |
df5168c4 MB |
589 | size_t GetCount() const { return base_array::size(); } \ |
590 | size_t size() const { return base_array::size(); } \ | |
591 | bool IsEmpty() const { return base_array::empty(); } \ | |
009c4392 | 592 | bool empty() const { return base_array::empty(); } \ |
df5168c4 MB |
593 | size_t Count() const { return base_array::size(); } \ |
594 | void Shrink() { base::Shrink(); } \ | |
595 | \ | |
5a1cad6e | 596 | T& operator[](size_t uiIndex) const \ |
df5168c4 | 597 | { return *(T*)base::operator[](uiIndex); } \ |
5a1cad6e | 598 | T& Item(size_t uiIndex) const \ |
df5168c4 | 599 | { return *(T*)base::operator[](uiIndex); } \ |
5a1cad6e | 600 | T& Last() const \ |
df5168c4 | 601 | { return *(T*)(base::operator[](size() - 1)); } \ |
5a1cad6e | 602 | \ |
222702b1 | 603 | int Index(const T& lItem, bool bFromEnd = false) const; \ |
5a1cad6e | 604 | \ |
222702b1 | 605 | void Add(const T& lItem, size_t nInsert = 1); \ |
5a1cad6e | 606 | void Add(const T* pItem) \ |
df5168c4 MB |
607 | { base::push_back((T*)pItem); } \ |
608 | void push_back(const T* pItem) \ | |
609 | { base::push_back((T*)pItem); } \ | |
222702b1 WS |
610 | void push_back(const T& lItem) \ |
611 | { Add(lItem); } \ | |
5a1cad6e | 612 | \ |
222702b1 | 613 | void Insert(const T& lItem, size_t uiIndex, size_t nInsert = 1); \ |
5a1cad6e | 614 | void Insert(const T* pItem, size_t uiIndex) \ |
df5168c4 | 615 | { base::insert(begin() + uiIndex, (T*)pItem); } \ |
5a1cad6e | 616 | \ |
df5168c4 MB |
617 | void Empty() { DoEmpty(); base::clear(); } \ |
618 | void Clear() { DoEmpty(); base::clear(); } \ | |
5a1cad6e GD |
619 | \ |
620 | T* Detach(size_t uiIndex) \ | |
df5168c4 MB |
621 | { T* p = (T*)base::operator[](uiIndex); \ |
622 | base::erase(begin() + uiIndex); return p; } \ | |
3b0b5f13 | 623 | void RemoveAt(size_t uiIndex, size_t nRemove = 1); \ |
5a1cad6e GD |
624 | \ |
625 | void Sort(CMPFUNC##T fCmp) { base::Sort((CMPFUNC##base)fCmp); } \ | |
626 | \ | |
627 | private: \ | |
628 | void DoEmpty(); \ | |
629 | void DoCopy(const name& src); \ | |
c801d85f KB |
630 | } |
631 | ||
1a931653 VZ |
632 | // ============================================================================ |
633 | // The public macros for declaration and definition of the dynamic arrays | |
634 | // ============================================================================ | |
635 | ||
636 | // Please note that for each macro WX_FOO_ARRAY we also have | |
637 | // WX_FOO_EXPORTED_ARRAY and WX_FOO_USER_EXPORTED_ARRAY which are exactly the | |
638 | // same except that they use an additional __declspec(dllexport) or equivalent | |
639 | // under Windows if needed. | |
640 | // | |
77ffb593 | 641 | // The first (just EXPORTED) macros do it if wxWidgets was compiled as a DLL |
1a931653 VZ |
642 | // and so must be used used inside the library. The second kind (USER_EXPORTED) |
643 | // allow the user code to do it when it wants. This is needed if you have a dll | |
644 | // that wants to export a wxArray daubed with your own import/export goo. | |
645 | // | |
646 | // Finally, you can define the macro below as something special to modify the | |
647 | // arrays defined by a simple WX_FOO_ARRAY as well. By default is is empty. | |
648 | #define wxARRAY_DEFAULT_EXPORT | |
649 | ||
650 | // ---------------------------------------------------------------------------- | |
5a1cad6e GD |
651 | // WX_DECLARE_BASEARRAY(T, name) declare an array class named "name" containing |
652 | // the elements of type T | |
653 | // ---------------------------------------------------------------------------- | |
654 | ||
655 | #define WX_DECLARE_BASEARRAY(T, name) \ | |
656 | WX_DECLARE_USER_EXPORTED_BASEARRAY(T, name, wxARRAY_DEFAULT_EXPORT) | |
657 | ||
658 | #define WX_DECLARE_EXPORTED_BASEARRAY(T, name) \ | |
53a2db12 | 659 | WX_DECLARE_USER_EXPORTED_BASEARRAY(T, name, WXDLLIMPEXP_CORE) |
5a1cad6e GD |
660 | |
661 | #define WX_DECLARE_USER_EXPORTED_BASEARRAY(T, name, expmode) \ | |
662 | typedef T _wxArray##name; \ | |
663 | _WX_DECLARE_BASEARRAY(_wxArray##name, name, class expmode) | |
664 | ||
665 | // ---------------------------------------------------------------------------- | |
666 | // WX_DEFINE_TYPEARRAY(T, name, base) define an array class named "name" deriving | |
667 | // from class "base" containing the elements of type T | |
1a931653 VZ |
668 | // |
669 | // Note that the class defined has only inline function and doesn't take any | |
670 | // space at all so there is no size penalty for defining multiple array classes | |
c801d85f | 671 | // ---------------------------------------------------------------------------- |
c801d85f | 672 | |
5a1cad6e | 673 | #define WX_DEFINE_TYPEARRAY(T, name, base) \ |
68559fd5 | 674 | WX_DEFINE_TYPEARRAY_WITH_DECL(T, name, base, class wxARRAY_DEFAULT_EXPORT) |
1a931653 | 675 | |
d5d29b8a VZ |
676 | #define WX_DEFINE_TYPEARRAY_PTR(T, name, base) \ |
677 | WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, base, class wxARRAY_DEFAULT_EXPORT) | |
6108e3fd | 678 | |
5a1cad6e | 679 | #define WX_DEFINE_EXPORTED_TYPEARRAY(T, name, base) \ |
53a2db12 | 680 | WX_DEFINE_TYPEARRAY_WITH_DECL(T, name, base, class WXDLLIMPEXP_CORE) |
1a931653 | 681 | |
d5d29b8a | 682 | #define WX_DEFINE_EXPORTED_TYPEARRAY_PTR(T, name, base) \ |
53a2db12 | 683 | WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, base, class WXDLLIMPEXP_CORE) |
6108e3fd | 684 | |
68559fd5 VZ |
685 | #define WX_DEFINE_USER_EXPORTED_TYPEARRAY(T, name, base, expdecl) \ |
686 | WX_DEFINE_TYPEARRAY_WITH_DECL(T, name, base, class expdecl) | |
687 | ||
d5d29b8a VZ |
688 | #define WX_DEFINE_USER_EXPORTED_TYPEARRAY_PTR(T, name, base, expdecl) \ |
689 | WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, base, class expdecl) | |
6108e3fd | 690 | |
68559fd5 | 691 | #define WX_DEFINE_TYPEARRAY_WITH_DECL(T, name, base, classdecl) \ |
df5168c4 | 692 | typedef T _wxArray##name; \ |
68559fd5 | 693 | _WX_DEFINE_TYPEARRAY(_wxArray##name, name, base, classdecl) |
1a931653 | 694 | |
d5d29b8a | 695 | #define WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, base, classdecl) \ |
6108e3fd | 696 | typedef T _wxArray##name; \ |
d5d29b8a | 697 | _WX_DEFINE_TYPEARRAY_PTR(_wxArray##name, name, base, classdecl) |
6108e3fd | 698 | |
1a931653 | 699 | // ---------------------------------------------------------------------------- |
5a1cad6e | 700 | // WX_DEFINE_SORTED_TYPEARRAY: this is the same as the previous macro, but it |
1a931653 VZ |
701 | // defines a sorted array. |
702 | // | |
703 | // Differences: | |
704 | // 1) it must be given a COMPARE function in ctor which takes 2 items of type | |
705 | // T* and should return -1, 0 or +1 if the first one is less/greater | |
706 | // than/equal to the second one. | |
707 | // 2) the Add() method inserts the item in such was that the array is always | |
708 | // sorted (it uses the COMPARE function) | |
709 | // 3) it has no Sort() method because it's always sorted | |
710 | // 4) Index() method is much faster (the sorted arrays use binary search | |
711 | // instead of linear one), but Add() is slower. | |
712 | // 5) there is no Insert() method because you can't insert an item into the | |
713 | // given position in a sorted array but there is IndexForInsert()/AddAt() | |
714 | // pair which may be used to optimize a common operation of "insert only if | |
715 | // not found" | |
716 | // | |
717 | // Note that you have to specify the comparison function when creating the | |
718 | // objects of this array type. If, as in 99% of cases, the comparison function | |
5a1cad6e GD |
719 | // is the same for all objects of a class, WX_DEFINE_SORTED_TYPEARRAY_CMP below |
720 | // is more convenient. | |
1a931653 VZ |
721 | // |
722 | // Summary: use this class when the speed of Index() function is important, use | |
723 | // the normal arrays otherwise. | |
c801d85f KB |
724 | // ---------------------------------------------------------------------------- |
725 | ||
c75cc2e8 VZ |
726 | // we need a macro which expands to nothing to pass correct number of |
727 | // parameters to a nested macro invocation even when we don't have anything to | |
728 | // pass it | |
729 | #define wxARRAY_EMPTY | |
17e656b0 | 730 | |
5a1cad6e GD |
731 | #define WX_DEFINE_SORTED_TYPEARRAY(T, name, base) \ |
732 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, base, \ | |
733 | wxARRAY_DEFAULT_EXPORT) | |
a497618a | 734 | |
5a1cad6e | 735 | #define WX_DEFINE_SORTED_EXPORTED_TYPEARRAY(T, name, base) \ |
53a2db12 | 736 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, base, WXDLLIMPEXP_CORE) |
a497618a | 737 | |
5a1cad6e GD |
738 | #define WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, base, expmode) \ |
739 | typedef T _wxArray##name; \ | |
3e49e577 MB |
740 | typedef int (CMPFUNC_CONV *SCMPFUNC##name)(T pItem1, T pItem2); \ |
741 | _WX_DEFINE_SORTED_TYPEARRAY_2(_wxArray##name, name, base, \ | |
c75cc2e8 | 742 | wxARRAY_EMPTY, class expmode, SCMPFUNC##name) |
1a931653 VZ |
743 | |
744 | // ---------------------------------------------------------------------------- | |
5a1cad6e | 745 | // WX_DEFINE_SORTED_TYPEARRAY_CMP: exactly the same as above but the comparison |
1a931653 VZ |
746 | // function is provided by this macro and the objects of this class have a |
747 | // default constructor which just uses it. | |
748 | // | |
749 | // The arguments are: the element type, the comparison function and the array | |
750 | // name | |
751 | // | |
5a1cad6e GD |
752 | // NB: this is, of course, how WX_DEFINE_SORTED_TYPEARRAY() should have worked |
753 | // from the very beginning - unfortunately I didn't think about this earlier | |
1a931653 | 754 | // ---------------------------------------------------------------------------- |
76314141 | 755 | |
5a1cad6e GD |
756 | #define WX_DEFINE_SORTED_TYPEARRAY_CMP(T, cmpfunc, name, base) \ |
757 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, base, \ | |
758 | wxARRAY_DEFAULT_EXPORT) | |
76314141 | 759 | |
5a1cad6e GD |
760 | #define WX_DEFINE_SORTED_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, base) \ |
761 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, base, \ | |
53a2db12 | 762 | WXDLLIMPEXP_CORE) |
1a931653 | 763 | |
5a1cad6e GD |
764 | #define WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, base, \ |
765 | expmode) \ | |
1a931653 | 766 | typedef T _wxArray##name; \ |
3e49e577 MB |
767 | typedef int (CMPFUNC_CONV *SCMPFUNC##name)(T pItem1, T pItem2); \ |
768 | _WX_DEFINE_SORTED_TYPEARRAY_2(_wxArray##name, name, base, = cmpfunc, \ | |
769 | class expmode, SCMPFUNC##name) | |
1a931653 VZ |
770 | |
771 | // ---------------------------------------------------------------------------- | |
772 | // WX_DECLARE_OBJARRAY(T, name): this macro generates a new array class | |
773 | // named "name" which owns the objects of type T it contains, i.e. it will | |
774 | // delete them when it is destroyed. | |
775 | // | |
776 | // An element is of type T*, but arguments of type T& are taken (see below!) | |
777 | // and T& is returned. | |
778 | // | |
779 | // Don't use this for simple types such as "int" or "long"! | |
1a931653 VZ |
780 | // |
781 | // Note on Add/Insert functions: | |
782 | // 1) function(T*) gives the object to the array, i.e. it will delete the | |
783 | // object when it's removed or in the array's dtor | |
784 | // 2) function(T&) will create a copy of the object and work with it | |
785 | // | |
786 | // Also: | |
787 | // 1) Remove() will delete the object after removing it from the array | |
788 | // 2) Detach() just removes the object from the array (returning pointer to it) | |
789 | // | |
790 | // NB1: Base type T should have an accessible copy ctor if Add(T&) is used | |
791 | // NB2: Never ever cast a array to it's base type: as dtor is not virtual | |
792 | // and so you risk having at least the memory leaks and probably worse | |
793 | // | |
794 | // Some functions of this class are not inline, so it takes some space to | |
795 | // define new class from this template even if you don't use it - which is not | |
796 | // the case for the simple (non-object) array classes | |
797 | // | |
1a931653 VZ |
798 | // To use an objarray class you must |
799 | // #include "dynarray.h" | |
800 | // WX_DECLARE_OBJARRAY(element_type, list_class_name) | |
801 | // #include "arrimpl.cpp" | |
802 | // WX_DEFINE_OBJARRAY(list_class_name) // name must be the same as above! | |
803 | // | |
804 | // This is necessary because at the moment of DEFINE_OBJARRAY class parsing the | |
805 | // element_type must be fully defined (i.e. forward declaration is not | |
806 | // enough), while WX_DECLARE_OBJARRAY may be done anywhere. The separation of | |
807 | // two allows to break cicrcular dependencies with classes which have member | |
808 | // variables of objarray type. | |
809 | // ---------------------------------------------------------------------------- | |
810 | ||
811 | #define WX_DECLARE_OBJARRAY(T, name) \ | |
812 | WX_DECLARE_USER_EXPORTED_OBJARRAY(T, name, wxARRAY_DEFAULT_EXPORT) | |
813 | ||
814 | #define WX_DECLARE_EXPORTED_OBJARRAY(T, name) \ | |
53a2db12 | 815 | WX_DECLARE_USER_EXPORTED_OBJARRAY(T, name, WXDLLIMPEXP_CORE) |
1a931653 | 816 | |
fd68cfdb | 817 | #define WX_DECLARE_OBJARRAY_WITH_DECL(T, name, decl) \ |
1a931653 | 818 | typedef T _wxObjArray##name; \ |
fd68cfdb | 819 | _WX_DECLARE_OBJARRAY(_wxObjArray##name, name, wxArrayPtrVoid, decl) |
68379eaf | 820 | |
fd68cfdb VS |
821 | #define WX_DECLARE_USER_EXPORTED_OBJARRAY(T, name, expmode) \ |
822 | WX_DECLARE_OBJARRAY_WITH_DECL(T, name, class expmode) | |
1a931653 VZ |
823 | |
824 | // WX_DEFINE_OBJARRAY is going to be redefined when arrimpl.cpp is included, | |
825 | // try to provoke a human-understandable error if it used incorrectly. | |
826 | // | |
827 | // there is no real need for 3 different macros in the DEFINE case but do it | |
828 | // anyhow for consistency | |
829 | #define WX_DEFINE_OBJARRAY(name) DidYouIncludeArrimplCpp | |
830 | #define WX_DEFINE_EXPORTED_OBJARRAY(name) WX_DEFINE_OBJARRAY(name) | |
76314141 | 831 | #define WX_DEFINE_USER_EXPORTED_OBJARRAY(name) WX_DEFINE_OBJARRAY(name) |
76314141 | 832 | |
5a1cad6e GD |
833 | // ---------------------------------------------------------------------------- |
834 | // Some commonly used predefined base arrays | |
835 | // ---------------------------------------------------------------------------- | |
836 | ||
eee614d3 VS |
837 | WX_DECLARE_USER_EXPORTED_BASEARRAY(const void *, wxBaseArrayPtrVoid, |
838 | WXDLLIMPEXP_BASE); | |
1ffc8d7a | 839 | WX_DECLARE_USER_EXPORTED_BASEARRAY(char, wxBaseArrayChar, WXDLLIMPEXP_BASE); |
6108e3fd VZ |
840 | WX_DECLARE_USER_EXPORTED_BASEARRAY(short, wxBaseArrayShort, WXDLLIMPEXP_BASE); |
841 | WX_DECLARE_USER_EXPORTED_BASEARRAY(int, wxBaseArrayInt, WXDLLIMPEXP_BASE); | |
842 | WX_DECLARE_USER_EXPORTED_BASEARRAY(long, wxBaseArrayLong, WXDLLIMPEXP_BASE); | |
d2213b1f | 843 | WX_DECLARE_USER_EXPORTED_BASEARRAY(size_t, wxBaseArraySizeT, WXDLLIMPEXP_BASE); |
6108e3fd | 844 | WX_DECLARE_USER_EXPORTED_BASEARRAY(double, wxBaseArrayDouble, WXDLLIMPEXP_BASE); |
5a1cad6e GD |
845 | |
846 | // ---------------------------------------------------------------------------- | |
847 | // Convenience macros to define arrays from base arrays | |
848 | // ---------------------------------------------------------------------------- | |
849 | ||
850 | #define WX_DEFINE_ARRAY(T, name) \ | |
851 | WX_DEFINE_TYPEARRAY(T, name, wxBaseArrayPtrVoid) | |
d5d29b8a VZ |
852 | #define WX_DEFINE_ARRAY_PTR(T, name) \ |
853 | WX_DEFINE_TYPEARRAY_PTR(T, name, wxBaseArrayPtrVoid) | |
5a1cad6e GD |
854 | #define WX_DEFINE_EXPORTED_ARRAY(T, name) \ |
855 | WX_DEFINE_EXPORTED_TYPEARRAY(T, name, wxBaseArrayPtrVoid) | |
d5d29b8a VZ |
856 | #define WX_DEFINE_EXPORTED_ARRAY_PTR(T, name) \ |
857 | WX_DEFINE_EXPORTED_TYPEARRAY_PTR(T, name, wxBaseArrayPtrVoid) | |
858 | #define WX_DEFINE_ARRAY_WITH_DECL_PTR(T, name, decl) \ | |
859 | WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, wxBaseArrayPtrVoid, decl) | |
5a1cad6e | 860 | #define WX_DEFINE_USER_EXPORTED_ARRAY(T, name, expmode) \ |
c75cc2e8 | 861 | WX_DEFINE_TYPEARRAY_WITH_DECL(T, name, wxBaseArrayPtrVoid, wxARRAY_EMPTY expmode) |
d5d29b8a | 862 | #define WX_DEFINE_USER_EXPORTED_ARRAY_PTR(T, name, expmode) \ |
c75cc2e8 | 863 | WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, wxBaseArrayPtrVoid, wxARRAY_EMPTY expmode) |
5a1cad6e | 864 | |
1ffc8d7a VZ |
865 | #define WX_DEFINE_ARRAY_CHAR(T, name) \ |
866 | WX_DEFINE_TYPEARRAY_PTR(T, name, wxBaseArrayChar) | |
867 | #define WX_DEFINE_EXPORTED_ARRAY_CHAR(T, name) \ | |
868 | WX_DEFINE_EXPORTED_TYPEARRAY_PTR(T, name, wxBaseArrayChar) | |
869 | #define WX_DEFINE_USER_EXPORTED_ARRAY_CHAR(T, name, expmode) \ | |
c75cc2e8 | 870 | WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, wxBaseArrayChar, wxARRAY_EMPTY expmode) |
1ffc8d7a | 871 | |
5a1cad6e | 872 | #define WX_DEFINE_ARRAY_SHORT(T, name) \ |
d5d29b8a | 873 | WX_DEFINE_TYPEARRAY_PTR(T, name, wxBaseArrayShort) |
5a1cad6e | 874 | #define WX_DEFINE_EXPORTED_ARRAY_SHORT(T, name) \ |
d5d29b8a | 875 | WX_DEFINE_EXPORTED_TYPEARRAY_PTR(T, name, wxBaseArrayShort) |
5a1cad6e | 876 | #define WX_DEFINE_USER_EXPORTED_ARRAY_SHORT(T, name, expmode) \ |
c75cc2e8 | 877 | WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, wxBaseArrayShort, wxARRAY_EMPTY expmode) |
5a1cad6e GD |
878 | |
879 | #define WX_DEFINE_ARRAY_INT(T, name) \ | |
d5d29b8a | 880 | WX_DEFINE_TYPEARRAY_PTR(T, name, wxBaseArrayInt) |
5a1cad6e | 881 | #define WX_DEFINE_EXPORTED_ARRAY_INT(T, name) \ |
d5d29b8a | 882 | WX_DEFINE_EXPORTED_TYPEARRAY_PTR(T, name, wxBaseArrayInt) |
5a1cad6e | 883 | #define WX_DEFINE_USER_EXPORTED_ARRAY_INT(T, name, expmode) \ |
c75cc2e8 | 884 | WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, wxBaseArrayInt, wxARRAY_EMPTY expmode) |
5a1cad6e GD |
885 | |
886 | #define WX_DEFINE_ARRAY_LONG(T, name) \ | |
d5d29b8a | 887 | WX_DEFINE_TYPEARRAY_PTR(T, name, wxBaseArrayLong) |
5a1cad6e | 888 | #define WX_DEFINE_EXPORTED_ARRAY_LONG(T, name) \ |
d5d29b8a | 889 | WX_DEFINE_EXPORTED_TYPEARRAY_PTR(T, name, wxBaseArrayLong) |
5a1cad6e | 890 | #define WX_DEFINE_USER_EXPORTED_ARRAY_LONG(T, name, expmode) \ |
c75cc2e8 | 891 | WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, wxBaseArrayLong, wxARRAY_EMPTY expmode) |
5a1cad6e | 892 | |
d2213b1f VZ |
893 | #define WX_DEFINE_ARRAY_SIZE_T(T, name) \ |
894 | WX_DEFINE_TYPEARRAY_PTR(T, name, wxBaseArraySizeT) | |
895 | #define WX_DEFINE_EXPORTED_ARRAY_SIZE_T(T, name) \ | |
896 | WX_DEFINE_EXPORTED_TYPEARRAY_PTR(T, name, wxBaseArraySizeT) | |
897 | #define WX_DEFINE_USER_EXPORTED_ARRAY_SIZE_T(T, name, expmode) \ | |
c75cc2e8 | 898 | WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, wxBaseArraySizeT, wxARRAY_EMPTY expmode) |
d2213b1f | 899 | |
5a1cad6e | 900 | #define WX_DEFINE_ARRAY_DOUBLE(T, name) \ |
d5d29b8a | 901 | WX_DEFINE_TYPEARRAY_PTR(T, name, wxBaseArrayDouble) |
5a1cad6e | 902 | #define WX_DEFINE_EXPORTED_ARRAY_DOUBLE(T, name) \ |
d5d29b8a | 903 | WX_DEFINE_EXPORTED_TYPEARRAY_PTR(T, name, wxBaseArrayDouble) |
5a1cad6e | 904 | #define WX_DEFINE_USER_EXPORTED_ARRAY_DOUBLE(T, name, expmode) \ |
c75cc2e8 | 905 | WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, wxBaseArrayDouble, wxARRAY_EMPTY expmode) |
5a1cad6e GD |
906 | |
907 | // ---------------------------------------------------------------------------- | |
908 | // Convenience macros to define sorted arrays from base arrays | |
909 | // ---------------------------------------------------------------------------- | |
910 | ||
911 | #define WX_DEFINE_SORTED_ARRAY(T, name) \ | |
912 | WX_DEFINE_SORTED_TYPEARRAY(T, name, wxBaseArrayPtrVoid) | |
913 | #define WX_DEFINE_SORTED_EXPORTED_ARRAY(T, name) \ | |
914 | WX_DEFINE_SORTED_EXPORTED_TYPEARRAY(T, name, wxBaseArrayPtrVoid) | |
915 | #define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY(T, name, expmode) \ | |
c75cc2e8 | 916 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArrayPtrVoid, wxARRAY_EMPTY expmode) |
5a1cad6e | 917 | |
1ffc8d7a VZ |
918 | #define WX_DEFINE_SORTED_ARRAY_CHAR(T, name) \ |
919 | WX_DEFINE_SORTED_TYPEARRAY(T, name, wxBaseArrayChar) | |
920 | #define WX_DEFINE_SORTED_EXPORTED_ARRAY_CHAR(T, name) \ | |
921 | WX_DEFINE_SORTED_EXPORTED_TYPEARRAY(T, name, wxBaseArrayChar) | |
922 | #define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_CHAR(T, name, expmode) \ | |
c75cc2e8 | 923 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArrayChar, wxARRAY_EMPTY expmode) |
1ffc8d7a | 924 | |
5a1cad6e GD |
925 | #define WX_DEFINE_SORTED_ARRAY_SHORT(T, name) \ |
926 | WX_DEFINE_SORTED_TYPEARRAY(T, name, wxBaseArrayShort) | |
927 | #define WX_DEFINE_SORTED_EXPORTED_ARRAY_SHORT(T, name) \ | |
928 | WX_DEFINE_SORTED_EXPORTED_TYPEARRAY(T, name, wxBaseArrayShort) | |
929 | #define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_SHORT(T, name, expmode) \ | |
c75cc2e8 | 930 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArrayShort, wxARRAY_EMPTY expmode) |
5a1cad6e GD |
931 | |
932 | #define WX_DEFINE_SORTED_ARRAY_INT(T, name) \ | |
933 | WX_DEFINE_SORTED_TYPEARRAY(T, name, wxBaseArrayInt) | |
934 | #define WX_DEFINE_SORTED_EXPORTED_ARRAY_INT(T, name) \ | |
935 | WX_DEFINE_SORTED_EXPORTED_TYPEARRAY(T, name, wxBaseArrayInt) | |
936 | #define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_INT(T, name, expmode) \ | |
937 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArrayInt, expmode) | |
938 | ||
939 | #define WX_DEFINE_SORTED_ARRAY_LONG(T, name) \ | |
940 | WX_DEFINE_SORTED_TYPEARRAY(T, name, wxBaseArrayLong) | |
941 | #define WX_DEFINE_SORTED_EXPORTED_ARRAY_LONG(T, name) \ | |
942 | WX_DEFINE_SORTED_EXPORTED_TYPEARRAY(T, name, wxBaseArrayLong) | |
943 | #define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_LONG(T, name, expmode) \ | |
944 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArrayLong, expmode) | |
945 | ||
d2213b1f VZ |
946 | #define WX_DEFINE_SORTED_ARRAY_SIZE_T(T, name) \ |
947 | WX_DEFINE_SORTED_TYPEARRAY(T, name, wxBaseArraySizeT) | |
948 | #define WX_DEFINE_SORTED_EXPORTED_ARRAY_SIZE_T(T, name) \ | |
949 | WX_DEFINE_SORTED_EXPORTED_TYPEARRAY(T, name, wxBaseArraySizeT) | |
950 | #define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_SIZE_T(T, name, expmode) \ | |
c75cc2e8 | 951 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArraySizeT, wxARRAY_EMPTY expmode) |
d2213b1f | 952 | |
5a1cad6e GD |
953 | // ---------------------------------------------------------------------------- |
954 | // Convenience macros to define sorted arrays from base arrays | |
955 | // ---------------------------------------------------------------------------- | |
956 | ||
957 | #define WX_DEFINE_SORTED_ARRAY_CMP(T, cmpfunc, name) \ | |
958 | WX_DEFINE_SORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayPtrVoid) | |
959 | #define WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP(T, cmpfunc, name) \ | |
960 | WX_DEFINE_SORTED_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayPtrVoid) | |
961 | #define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_CMP(T, cmpfunc, \ | |
962 | name, expmode) \ | |
963 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, \ | |
c75cc2e8 VZ |
964 | wxBaseArrayPtrVoid, \ |
965 | wxARRAY_EMPTY expmode) | |
5a1cad6e | 966 | |
1ffc8d7a VZ |
967 | #define WX_DEFINE_SORTED_ARRAY_CMP_CHAR(T, cmpfunc, name) \ |
968 | WX_DEFINE_SORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayChar) | |
969 | #define WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP_CHAR(T, cmpfunc, name) \ | |
970 | WX_DEFINE_SORTED_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayChar) | |
c75cc2e8 | 971 | #define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_CMP_CHAR(T, cmpfunc, \ |
1ffc8d7a VZ |
972 | name, expmode) \ |
973 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, \ | |
c75cc2e8 VZ |
974 | wxBaseArrayChar, \ |
975 | wxARRAY_EMPTY expmode) | |
1ffc8d7a | 976 | |
5a1cad6e GD |
977 | #define WX_DEFINE_SORTED_ARRAY_CMP_SHORT(T, cmpfunc, name) \ |
978 | WX_DEFINE_SORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayShort) | |
979 | #define WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP_SHORT(T, cmpfunc, name) \ | |
980 | WX_DEFINE_SORTED_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayShort) | |
981 | #define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_CMP_SHORT(T, cmpfunc, \ | |
982 | name, expmode) \ | |
983 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, \ | |
c75cc2e8 VZ |
984 | wxBaseArrayShort, \ |
985 | wxARRAY_EMPTY expmode) | |
5a1cad6e GD |
986 | |
987 | #define WX_DEFINE_SORTED_ARRAY_CMP_INT(T, cmpfunc, name) \ | |
988 | WX_DEFINE_SORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayInt) | |
989 | #define WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP_INT(T, cmpfunc, name) \ | |
990 | WX_DEFINE_SORTED_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayInt) | |
991 | #define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_CMP_INT(T, cmpfunc, \ | |
992 | name, expmode) \ | |
993 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, \ | |
c75cc2e8 VZ |
994 | wxBaseArrayInt, \ |
995 | wxARRAY_EMPTY expmode) | |
5a1cad6e GD |
996 | |
997 | #define WX_DEFINE_SORTED_ARRAY_CMP_LONG(T, cmpfunc, name) \ | |
998 | WX_DEFINE_SORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayLong) | |
999 | #define WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP_LONG(T, cmpfunc, name) \ | |
1000 | WX_DEFINE_SORTED_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayLong) | |
1001 | #define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_CMP_LONG(T, cmpfunc, \ | |
1002 | name, expmode) \ | |
1003 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, \ | |
c75cc2e8 VZ |
1004 | wxBaseArrayLong, \ |
1005 | wxARRAY_EMPTY expmode) | |
5a1cad6e | 1006 | |
d2213b1f VZ |
1007 | #define WX_DEFINE_SORTED_ARRAY_CMP_SIZE_T(T, cmpfunc, name) \ |
1008 | WX_DEFINE_SORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArraySizeT) | |
1009 | #define WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP_SIZE_T(T, cmpfunc, name) \ | |
1010 | WX_DEFINE_SORTED_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArraySizeT) | |
1011 | #define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_CMP_SIZE_T(T, cmpfunc, \ | |
1012 | name, expmode) \ | |
1013 | WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, \ | |
c75cc2e8 VZ |
1014 | wxBaseArraySizeT, \ |
1015 | wxARRAY_EMPTY expmode) | |
d2213b1f | 1016 | |
c801d85f | 1017 | // ---------------------------------------------------------------------------- |
1a931653 | 1018 | // Some commonly used predefined arrays |
c801d85f KB |
1019 | // ---------------------------------------------------------------------------- |
1020 | ||
6108e3fd VZ |
1021 | WX_DEFINE_USER_EXPORTED_ARRAY_SHORT(short, wxArrayShort, class WXDLLIMPEXP_BASE); |
1022 | WX_DEFINE_USER_EXPORTED_ARRAY_INT(int, wxArrayInt, class WXDLLIMPEXP_BASE); | |
87cc1cc7 | 1023 | WX_DEFINE_USER_EXPORTED_ARRAY_DOUBLE(double, wxArrayDouble, class WXDLLIMPEXP_BASE); |
6108e3fd | 1024 | WX_DEFINE_USER_EXPORTED_ARRAY_LONG(long, wxArrayLong, class WXDLLIMPEXP_BASE); |
d5d29b8a | 1025 | WX_DEFINE_USER_EXPORTED_ARRAY_PTR(void *, wxArrayPtrVoid, class WXDLLIMPEXP_BASE); |
c801d85f | 1026 | |
2b9bd418 | 1027 | // ----------------------------------------------------------------------------- |
0cbff120 | 1028 | // convenience macros |
2b9bd418 VZ |
1029 | // ----------------------------------------------------------------------------- |
1030 | ||
bf7f7793 RR |
1031 | // prepend all element of one array to another one; e.g. if first array contains |
1032 | // elements X,Y,Z and the second contains A,B,C (in those orders), then the | |
1033 | // first array will be result as A,B,C,X,Y,Z | |
1034 | #define WX_PREPEND_ARRAY(array, other) \ | |
1035 | { \ | |
1036 | size_t wxAAcnt = (other).size(); \ | |
cd643444 | 1037 | (array).reserve(wxAAcnt); \ |
bf7f7793 RR |
1038 | for ( size_t wxAAn = 0; wxAAn < wxAAcnt; wxAAn++ ) \ |
1039 | { \ | |
1040 | (array).Insert((other)[wxAAn], wxAAn); \ | |
1041 | } \ | |
1042 | } | |
1043 | ||
4f6aed9c VZ |
1044 | // append all element of one array to another one |
1045 | #define WX_APPEND_ARRAY(array, other) \ | |
1046 | { \ | |
17a1ebd1 | 1047 | size_t wxAAcnt = (other).size(); \ |
cd643444 | 1048 | (array).reserve(wxAAcnt); \ |
17a1ebd1 | 1049 | for ( size_t wxAAn = 0; wxAAn < wxAAcnt; wxAAn++ ) \ |
4f6aed9c | 1050 | { \ |
17a1ebd1 | 1051 | (array).push_back((other)[wxAAn]); \ |
4f6aed9c VZ |
1052 | } \ |
1053 | } | |
1054 | ||
2b9bd418 VZ |
1055 | // delete all array elements |
1056 | // | |
1057 | // NB: the class declaration of the array elements must be visible from the | |
1058 | // place where you use this macro, otherwise the proper destructor may not | |
1059 | // be called (a decent compiler should give a warning about it, but don't | |
1060 | // count on it)! | |
1061 | #define WX_CLEAR_ARRAY(array) \ | |
1062 | { \ | |
17a1ebd1 VZ |
1063 | size_t wxAAcnt = (array).size(); \ |
1064 | for ( size_t wxAAn = 0; wxAAn < wxAAcnt; wxAAn++ ) \ | |
2b9bd418 | 1065 | { \ |
17a1ebd1 | 1066 | delete (array)[wxAAn]; \ |
2b9bd418 | 1067 | } \ |
2c356747 | 1068 | \ |
df5168c4 | 1069 | (array).clear(); \ |
2b9bd418 | 1070 | } |
a497618a | 1071 | |
c801d85f | 1072 | #endif // _DYNARRAY_H |