+#define _WX_DEFINE_BASEARRAY_COMMON(T, name) \
+/* searches the array for an item (forward or backwards) */ \
+int name::Index(T lItem, bool bFromEnd) const \
+{ \
+ if ( bFromEnd ) { \
+ if ( size() > 0 ) { \
+ size_t n = size(); \
+ do { \
+ if ( (*this)[--n] == lItem ) \
+ return n; \
+ } \
+ while ( n != 0 ); \
+ } \
+ } \
+ else { \
+ for( size_t n = 0; n < size(); n++ ) { \
+ if( (*this)[n] == lItem ) \
+ return n; \
+ } \
+ } \
+ \
+ return wxNOT_FOUND; \
+} \
+ \
+/* add item assuming the array is sorted with fnCompare function */ \
+size_t name::Add(T lItem, CMPFUNC fnCompare) \
+{ \
+ size_t idx = IndexForInsert(lItem, fnCompare); \
+ Insert(lItem, idx); \
+ return idx; \
+}
+
+#if wxUSE_STL
+
+#define _WX_DEFINE_BASEARRAY_NOCOMMON(T, name) \
+size_t name::IndexForInsert(T lItem, CMPFUNC fnCompare) const \
+{ \
+ Predicate p((SCMPFUNC)fnCompare); \
+ const_iterator it = std::lower_bound(begin(), end(), lItem, p); \
+ return it - begin(); \
+} \
+ \
+int name::Index(T lItem, CMPFUNC fnCompare) const \
+{ \
+ Predicate p((SCMPFUNC)fnCompare); \
+ const_iterator it = std::lower_bound(begin(), end(), lItem, p); \
+ return (it != end() && \
+ p(lItem, *it)) ? (int)(it - begin()) : wxNOT_FOUND; \
+} \
+ \
+void name::Shrink() \
+{ \
+ name tmp(*this); \
+ swap(tmp); \
+}
+
+#else // if !wxUSE_STL
+
+#define _WX_DEFINE_BASEARRAY_NOCOMMON(T, name) \