Using RWUCollationKey
You can obtain a collation key for a given string using the
getCollationKey() method on
RWUCollator. For example:
RWUCollationKey myKey1 = myCollator.getCollationKey("RogueWave");
RWUCollationKey myKey2 = myCollator.getCollationKey("Software");
The returned key may be compared to other keys produced by collators with the same attributes. Note that generating a key using
RWUCollator::getCollationKey() not a trivial operation, as it involves determining the collation elements and weights for an entire string. Comparing two
RWUCollationKey objects, however, is fast.
Collation keys can be compared using logical operators ==, !=, and <. Thus:
if (myKey1 < myKey2) {
// Do something here
}
Collation keys can also be inserted into collections that use operators ==, !=, and < to order items. For example:
RWTValSortedVector<RWUCollationKey,
std::less<RWUCollationKey> > vector;
vector.insert(myKey1);
vector.insert(myKey2);
To get back the string associated with a collation key, use the getString() method:
RWUString str1 = myKey1.getString(); //str1 = "RogueWave"
RWUString str2 = myKey2.getString(); //str2 = "Software"