|
Provides dictionary ordering binary predicate function on strings. More...
#include <stringUtils.h>
Public Member Functions | |
bool | operator() (const std::string &lhs, const std::string &rhs) const |
Return true if lhs is less than rhs in dictionary order. | |
Provides dictionary ordering binary predicate function on strings.
The TfDictionaryLessThan
class is a functor as defined by the STL standard. It compares strings using "dictionary" order: for example, the following strings are in dictionary order: ["abacus", "Albert", "albert", "baby", "Bert", "file01", "file001", "file2", "file10"]
Note that capitalization matters only if the strings differ by capitalization alone.
Characters whose ASCII value are inbetween upper- and lowercase letters, such as underscore, are sorted to come after all letters.
ASCII strings will sort lexicographically according to the rules below. Strings with other Unicode characters will follow these same rules until a multi-byte codepoint is encountered in which case it will be byte compared with the bytes in the other string. Multi-byte encoded characters will operate this way for each of the bytes.
Note that this results in a non-lexicographic ordering of strings that contain non-ASCII characters. Clients interested in sorting strings lexicographically should not rely on this function for doing so and should instead use a custom sort function (or use one provided by an already existing library such as Qt or ICU).
Definition at line 511 of file stringUtils.h.
|
inline |
Return true if lhs
is less than rhs
in dictionary order.
Normally this functor is used to supply an ordering functor for STL containers: for example,
If you simply need to compare two strings, you can do so as follows:
Definition at line 524 of file stringUtils.h.