Allow specifying custom comparator for wxSortedArrayString.
Add a possibility to order wxSortedArrayString in some order different from the default alphabetical one. Closes #16330. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76751 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -85,6 +85,9 @@ public:
|
||||
for ( size_t n = 0; n < src.size(); n++ )
|
||||
Add(src[n]);
|
||||
}
|
||||
wxEXPLICIT wxSortedArrayString(wxArrayString::CompareFunction compareFunction)
|
||||
: wxSortedArrayStringBase(compareFunction)
|
||||
{ }
|
||||
|
||||
int Index(const wxString& str, bool bCase = true, bool bFromEnd = false) const;
|
||||
|
||||
@@ -342,6 +345,8 @@ protected:
|
||||
void Init(bool autoSort); // common part of all ctors
|
||||
void Copy(const wxArrayString& src); // copies the contents of another array
|
||||
|
||||
CompareFunction m_compareFunction; // set only from wxSortedArrayString
|
||||
|
||||
private:
|
||||
void Grow(size_t nIncrement = 0); // makes array bigger if needed
|
||||
|
||||
@@ -360,6 +365,10 @@ public:
|
||||
{ }
|
||||
wxSortedArrayString(const wxArrayString& array) : wxArrayString(true)
|
||||
{ Copy(array); }
|
||||
|
||||
wxEXPLICIT wxSortedArrayString(CompareFunction compareFunction)
|
||||
: wxArrayString(true)
|
||||
{ m_compareFunction = compareFunction; }
|
||||
};
|
||||
|
||||
#endif // !wxUSE_STD_CONTAINERS
|
||||
|
Reference in New Issue
Block a user