Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Essential Tools Module User's Guide

4.4 Lexicographic Comparisons

If you are putting together a dictionary, you will find the lexicographics comparison operators of RWCString particularly useful. They are:

These operators are case sensitive. If you wish to make case insensitive comparisons, you can use the member function:

Here the function returns an integer less than zero, equal to zero, or greater than zero, depending on whether str is lexicographically less than, equal to, or greater than self. The type caseCompare is an enum with values:

Its default setting is exact, which gives the same result as the logical operators ==, !=, etc.

For locale-specific string collations, you would use the member function:

which is an encapsulation of the Standard C library function strcoll(). This function returns results computed according to the locale-specific collating conventions set by category LC_COLLATE of the Standard C library function setlocale(). Because this is a relatively expensive calculation, you may want to pretransform one or more strings using the global function:

then use compareTo() or one of the logical operators, ==, !=, etc., on the results. See the Essential Tools Module Reference Guide entry for RWCString: the function strxForm() appears under related global functions.



Previous fileTop of DocumentContentsIndex pageNext file

©2004 Copyright Quovadx, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Quovadx, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.