///////////////////////////////////////////////////////////////////////////////
-// Name: dynarray.h
+// Name: wx/dynarray.h
// Purpose: auto-resizable (i.e. dynamic) array support
// Author: Vadim Zeitlin
// Modified by:
\
void Empty() { m_nCount = 0; } \
void Clear(); \
- void Alloc(size_t uiSize); \
+ void Alloc(size_t n) { if ( n > m_nSize ) Realloc(n); } \
void Shrink(); \
\
size_t GetCount() const { return m_nCount; } \
void insert(iterator it, const_iterator first, const_iterator last);\
void pop_back() { RemoveAt(size() - 1); } \
void push_back(const value_type& v) { Add(v); } \
- void reserve(size_type n) { if(n > m_nSize) Realloc(n); } \
+ void reserve(size_type n) { Alloc(n); } \
void resize(size_type n, value_type v = value_type()) \
{ SetCount(n, v); } \
\
WX_DECLARE_USER_EXPORTED_BASEARRAY(const void *, wxBaseArrayPtrVoid,
WXDLLIMPEXP_BASE);
+WX_DECLARE_USER_EXPORTED_BASEARRAY(char, wxBaseArrayChar, WXDLLIMPEXP_BASE);
WX_DECLARE_USER_EXPORTED_BASEARRAY(short, wxBaseArrayShort, WXDLLIMPEXP_BASE);
WX_DECLARE_USER_EXPORTED_BASEARRAY(int, wxBaseArrayInt, WXDLLIMPEXP_BASE);
WX_DECLARE_USER_EXPORTED_BASEARRAY(long, wxBaseArrayLong, WXDLLIMPEXP_BASE);
#define WX_DEFINE_USER_EXPORTED_ARRAY_PTR(T, name, expmode) \
WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, wxBaseArrayPtrVoid, expmode)
+#define WX_DEFINE_ARRAY_CHAR(T, name) \
+ WX_DEFINE_TYPEARRAY_PTR(T, name, wxBaseArrayChar)
+#define WX_DEFINE_EXPORTED_ARRAY_CHAR(T, name) \
+ WX_DEFINE_EXPORTED_TYPEARRAY_PTR(T, name, wxBaseArrayChar)
+#define WX_DEFINE_USER_EXPORTED_ARRAY_CHAR(T, name, expmode) \
+ WX_DEFINE_TYPEARRAY_WITH_DECL_PTR(T, name, wxBaseArrayChar, expmode)
+
#define WX_DEFINE_ARRAY_SHORT(T, name) \
WX_DEFINE_TYPEARRAY_PTR(T, name, wxBaseArrayShort)
#define WX_DEFINE_EXPORTED_ARRAY_SHORT(T, name) \
#define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY(T, name, expmode) \
WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArrayPtrVoid, expmode)
+#define WX_DEFINE_SORTED_ARRAY_CHAR(T, name) \
+ WX_DEFINE_SORTED_TYPEARRAY(T, name, wxBaseArrayChar)
+#define WX_DEFINE_SORTED_EXPORTED_ARRAY_CHAR(T, name) \
+ WX_DEFINE_SORTED_EXPORTED_TYPEARRAY(T, name, wxBaseArrayChar)
+#define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_CHAR(T, name, expmode) \
+ WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArrayChar, expmode)
+
#define WX_DEFINE_SORTED_ARRAY_SHORT(T, name) \
WX_DEFINE_SORTED_TYPEARRAY(T, name, wxBaseArrayShort)
#define WX_DEFINE_SORTED_EXPORTED_ARRAY_SHORT(T, name) \
WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, \
wxBaseArrayPtrVoid, expmode)
+#define WX_DEFINE_SORTED_ARRAY_CMP_CHAR(T, cmpfunc, name) \
+ WX_DEFINE_SORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayChar)
+#define WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP_CHAR(T, cmpfunc, name) \
+ WX_DEFINE_SORTED_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayChar)
+#define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_CMP_CHAR(T, cmpfunc, \
+ name, expmode) \
+ WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, \
+ wxBaseArrayChar, expmode)
+
#define WX_DEFINE_SORTED_ARRAY_CMP_SHORT(T, cmpfunc, name) \
WX_DEFINE_SORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayShort)
#define WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP_SHORT(T, cmpfunc, name) \
WX_DEFINE_USER_EXPORTED_ARRAY_SHORT(short, wxArrayShort, class WXDLLIMPEXP_BASE);
WX_DEFINE_USER_EXPORTED_ARRAY_INT(int, wxArrayInt, class WXDLLIMPEXP_BASE);
+WX_DEFINE_USER_EXPORTED_ARRAY_DOUBLE(double, wxArrayDouble, class WXDLLIMPEXP_BASE);
WX_DEFINE_USER_EXPORTED_ARRAY_LONG(long, wxArrayLong, class WXDLLIMPEXP_BASE);
WX_DEFINE_USER_EXPORTED_ARRAY_PTR(void *, wxArrayPtrVoid, class WXDLLIMPEXP_BASE);
// convenience macros
// -----------------------------------------------------------------------------
+// prepend all element of one array to another one; e.g. if first array contains
+// elements X,Y,Z and the second contains A,B,C (in those orders), then the
+// first array will be result as A,B,C,X,Y,Z
+#define WX_PREPEND_ARRAY(array, other) \
+ { \
+ size_t wxAAcnt = (other).size(); \
+ (array).Alloc(wxAAcnt); \
+ for ( size_t wxAAn = 0; wxAAn < wxAAcnt; wxAAn++ ) \
+ { \
+ (array).Insert((other)[wxAAn], wxAAn); \
+ } \
+ }
+
// append all element of one array to another one
#define WX_APPEND_ARRAY(array, other) \
{ \
size_t wxAAcnt = (other).size(); \
+ (array).Alloc(wxAAcnt); \
for ( size_t wxAAn = 0; wxAAn < wxAAcnt; wxAAn++ ) \
{ \
(array).push_back((other)[wxAAn]); \
}
#endif // _DYNARRAY_H
-