Logo Search packages:      
Sourcecode: icu version File versions  Download package

UChar32 UnicodeSet::charAt ( int32_t  index  )  const

Returns the character at the given index within this set, where the set is ordered by ascending code point. If the index is out of range, return (UChar32)-1. The inverse of this method is indexOf().

Parameters:
index an index from 0..size()-1
Returns:
the character at the given index, or (UChar32)-1. ICU 2.4
Returns the character at the given index within this set, where the set is ordered by ascending code point. If the index is out of range, return (UChar32)-1. The inverse of this method is indexOf().
Parameters:
index an index from 0..size()-1
Returns:
the character at the given index, or (UChar32)-1.

Definition at line 794 of file uniset.cpp.

Referenced by TransliteratorTest::TestAny(), and UnicodeSetTest::TestIndexOf().

                                              {
    if (index >= 0) {
        // len2 is the largest even integer <= len, that is, it is len
        // for even values and len-1 for odd values.  With odd values
        // the last entry is UNICODESET_HIGH.
        int32_t len2 = len & ~1;
        for (int32_t i=0; i < len2;) {
            UChar32 start = list[i++];
            int32_t count = list[i++] - start;
            if (index < count) {
                return (UChar32)(start + index);
            }
            index -= count;
        }
    }
    return (UChar32)-1;
}


Generated by  Doxygen 1.6.0   Back to index