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

#include <stringUtils.h>

Public Member Functions

TF_API 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.

Definition at line 504 of file stringUtils.h.

Member Function Documentation

TF_API bool TfDictionaryLessThan::operator() ( const std::string lhs,
const std::string rhs 
) const

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);

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