HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TfDictionaryLessThan Class Reference

#include <stringUtils.h>

Public Member Functions

bool operator() (const std::string &lhs, const std::string &rhs) const
 

Detailed Description

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.

Note
This comparison is used for the runtime to give a deterministic ordering to strings.

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 528 of file stringUtils.h.

Member Function Documentation

bool TfDictionaryLessThan::operator() ( const std::string lhs,
const std::string rhs 
) const
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,

map<string, DataType, TfDictionaryLessThan> table;

If you simply need to compare two strings, you can do so as follows:

bool aIsFirst = TfDictionaryLessThan()(aString, bString);

Definition at line 541 of file stringUtils.h.


The documentation for this class was generated from the following file: