int wxSortedArrayString::Index(const wxChar* sz, bool bCase, bool WXUNUSED(bFromEnd)) const { wxSortedArrayString::const_iterator it; wxString s(sz); if (bCase) it = std::lower_bound(begin(), end(), s, wxStringCompare(wxStrcmpCppWrapper)); else it = std::lower_bound(begin(), end(), s, wxStringCompare(wxStricmpCppWrapper)); if (it == end()) return wxNOT_FOUND; if (bCase) { if (wxStrcmp(it->c_str(), sz) != 0) return wxNOT_FOUND; } else { if (wxStricmp(it->c_str(), sz) != 0) return wxNOT_FOUND; } return it - begin(); }
void wxArrayString::Sort(CompareFunction function) { std::sort(begin(), end(), #if __cplusplus >= 201103L [function](const wxString& s1, const wxString& s2) { return function(s1, s2) < 0; } #else // C++98 version wxStringCompare(function) #endif // C++11/C++98 ); }
int wxSortedArrayString::Index(const wxString& str, bool WXUNUSED_UNLESS_DEBUG(bCase), bool WXUNUSED_UNLESS_DEBUG(bFromEnd)) const { wxASSERT_MSG( bCase && !bFromEnd, "search parameters ignored for sorted array" ); wxSortedArrayString::const_iterator it = std::lower_bound(begin(), end(), str, wxStringCompare(wxStringCmp())); if ( it == end() || str.Cmp(*it) != 0 ) return wxNOT_FOUND; return it - begin(); }
int wxSortedArrayString::Index(const wxString& str, bool WXUNUSED_UNLESS_DEBUG(bCase), bool WXUNUSED_UNLESS_DEBUG(bFromEnd)) const { wxASSERT_MSG( bCase && !bFromEnd, "search parameters ignored for sorted array" ); wxSortedArrayString::const_iterator it = std::lower_bound(begin(), end(), str, #if __cplusplus >= 201103L [](const wxString& s1, const wxString& s2) { return s1 < s2; } #else // C++98 version wxStringCompare(wxStringCmp()) #endif // C++11/C++98 ); if ( it == end() || str.Cmp(*it) != 0 ) return wxNOT_FOUND; return it - begin(); }
void wxArrayString::Sort(CompareFunction function) { std::sort(begin(), end(), wxStringCompare(function)); }