Refactor the natural string compare and sort algorithm
Add a new string fragment type for whitespace and punctuation which needs to be assessed separately from letters and symbols. Use wxUint64 instead of long for storing the value for numeric fragment. Use collate instead of compare for non-numeric fragments. Change names for the public comparison functions: wxWidgets provided function is now named wxCmpGenericNatural() and for common public use is wxCmpNatural() which calls a native function in wxMSW and wxCmpGenericNatural() elsewhere. Try harder in wxCmpNaturalGeneric() if wxRegEx is unavailable: do not just make a simple string comparison, but perform a case-insensitive collation. Make some other changes to simplify and possibly speed up the code.
This commit is contained in:
@@ -53,7 +53,7 @@ WXDLLIMPEXP_BASE
|
||||
int wxCMPFUNC_CONV wxCmpNatural(const wxString& s1, const wxString& s2);
|
||||
|
||||
WXDLLIMPEXP_BASE
|
||||
int wxCMPFUNC_CONV wxCmpNaturalNative(const wxString& s1, const wxString& s2);
|
||||
int wxCMPFUNC_CONV wxCmpNaturalGeneric(const wxString& s1, const wxString& s2);
|
||||
|
||||
inline int wxCMPFUNC_CONV wxNaturalStringSortAscending(const wxString& s1, const wxString& s2)
|
||||
{
|
||||
|
Reference in New Issue
Block a user