+// This is the same as the previous macro, but it defines a sorted array.
+// Differences:
+// 1) it must be given a COMPARE function in ctor which takes 2 items of type
+// T* and should return -1, 0 or +1 if the first one is less/greater
+// than/equal to the second one.
+// 2) the Add() method inserts the item in such was that the array is always
+// sorted (it uses the COMPARE function)
+// 3) it has no Sort() method because it's always sorted
+// 4) Index() method is much faster (the sorted arrays use binary search
+// instead of linear one), but Add() is slower.
+//
+// Summary: use this class when the speed of Index() function is important, use
+// the normal arrays otherwise.
+//
+// NB: it has only inline functions => takes no space at all
+// Mod by JACS: Salford C++ doesn't like 'var->operator=' syntax, as in:
+// { ((wxBaseArray *)this)->operator=((const wxBaseArray&)src);
+// so using a temporary variable instead.
+// ----------------------------------------------------------------------------
+#define _WX_DEFINE_SORTED_ARRAY(T, name, classexp) \
+typedef int (CMPFUNC_CONV *SCMPFUNC##T)(T pItem1, T pItem2); \
+classexp name : public wxBaseArray \
+{ \
+public: \
+ name(SCMPFUNC##T fn) \
+ { size_t type = sizeof(T); \
+ size_t sizelong = sizeof(long); \
+ if ( type > sizelong ) \
+ { wxFAIL_MSG( _WX_ERROR_SIZEOF ); } \
+ m_fnCompare = fn; \
+ } \
+ \
+ name& operator=(const name& src) \
+ { wxBaseArray* temp = (wxBaseArray*) this; \
+ (*temp) = ((const wxBaseArray&)src); \
+ m_fnCompare = src.m_fnCompare; \
+ return *this; } \
+ \
+ T& operator[](size_t uiIndex) const \
+ { return (T&)(wxBaseArray::Item(uiIndex)); } \
+ T& Item(size_t uiIndex) const \
+ { return (T&)(wxBaseArray::Item(uiIndex)); } \
+ T& Last() const \
+ { return (T&)(wxBaseArray::Item(Count() - 1)); } \
+ \
+ int Index(T Item) const \
+ { return wxBaseArray::Index((long)Item, (CMPFUNC)m_fnCompare); }\
+ \
+ void Add(T Item) \
+ { wxBaseArray::Add((long)Item, (CMPFUNC)m_fnCompare); } \
+ \
+ void Remove(size_t uiIndex) { wxBaseArray::Remove(uiIndex); } \
+ void Remove(T Item) \
+ { int iIndex = Index(Item); \
+ wxCHECK2_MSG( iIndex != wxNOT_FOUND, return, \
+ _WX_ERROR_REMOVE ); \
+ wxBaseArray::Remove((size_t)iIndex); } \
+ \
+private: \
+ SCMPFUNC##T m_fnCompare; \
+}
+
+// ----------------------------------------------------------------------------
+// see WX_DECLARE_OBJARRAY and WX_DEFINE_OBJARRAY